今天给大家分享那些C++坑人必备的代码:
1.鼠标乱显
#include<windows.h>
#include<ctime>
using namespace std;
int main()
{
int x=GetSystemMetrics(SM_CXSCREEN);
int y=GetSystemMetrics(SM_CYSCREEN);
srand(time(NULL));
while(1)
{
SetCursorPos(rand()%x,rand()%y);
}
return 0;
}
解决方式:Alt+F4结束运行窗口即可
2.鼠标锁定(建议不要运行,否则后果自负)
重要的事情说三遍:建议不要运行,否则后果自负!建议不要运行,否则后果自负!建议不要运行,否则后果自负!
#include<windows.h>
#include<ctime>
using namespace std;
int main()
{
int x=GetSystemMetrics(SM_CXSCREEN);
int y=GetSystemMetrics(SM_CYSCREEN);
srand(time(NULL));
while(1)
{
SetCursorPos(x/2,y/2);
}
return 0;
}