good
2026-10-15 16:52:51
发布于:浙江
如何编写一个C++程序来整蛊你的好基友? 原创
YXY317Coder2024-11-17 17:50:24博主文章分类:整蛊
文章标签c整蛊文章分类C/C后端开发阅读数1516
如何编写一个C程序来整蛊你的好基友
作者从网上搜集了一些 C代码 和一些作者自己的代码,带给了大家。
整蛊
按照危险性来排序
3星:你基友只会骂你几句(没有危险性) 4星:你基友可能会上你家打你(含部分解药) 5星:你基友会追着打你(含解药)
3星类
- 一直输出,换行
#include <bits/stdc++.h>
using namespace std;
int main() {
while (true){
cout << "你想对他显示的语句" << endl;
}
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
2. 一直输出,不换行
#include <bits/stdc++.h>
using namespace std;
int main() {
while (true){
cout << "你想对他显示的语句";
}
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
解药:尽快停止程序的运行,要不然输出窗口可能会崩溃。
- 给控制台换一个颜色(较有威慑力)
#include <bits/stdc++.h>
using namespace std;
int main() {
system("color 颜色编号");
return 0;
}
1.
2.
3.
4.
5.
6.
7.
颜色代码
颜色代码一共有两位,前一位是背景颜色,后一位是字的颜色。
代码
颜色
0
黑色
1
蓝色
2
绿色
3
浅绿色
4
红色
5
紫色
6
黄色
7
白色
8
灰色
9
淡蓝色
A
淡绿色
B
更淡的绿色
C
淡红色
D
淡紫色
E
淡黄色
F
亮白色
如何编写一个C++程序来整蛊你的好基友?_整蛊
4.一直输出很多东西 (配上第三个效果更好,可以用来装B)
#include <bits/stdc++.h>
using namespace std;
int main() {
system("dir/ s");
return 0;
}
1.
2.
3.
4.
5.
6.
7.
4星类(含部分解药)
弹窗类
弹窗代码
#include <bits/stdc++.h>
#include <windows.h> //必须要导入 windows.h,如果不是 windows 系统这个功能就实现不了
using namespace std;
int main() {
MessageBox(弹窗图标代码,"弹窗内容","弹窗标题",反馈键);
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
弹窗图标代码
弹窗图标代码
含义
NULL
不显示图标
MB_ICONEXCLAMATION
警告
MB_ICONWARNING
警告
MB_ICONINFORMATION
提示
MB_ICONASTERISK
提示
MB_ICONQUESTION
疑问
MB_ICONSTOP
禁止
MB_ICONERROR
禁止
MB_ICONHAND
禁止
反馈键:
反馈键
反馈键代码
MB_OK
确定
MB_ABORTRETRYIGNORE
中止、重试和忽略
MB_OKCANCEL
确定和取消
MB_RETRYCANCEL
重试和取消
MB_YESNO
是和否
MB_YESNOCANCEL
是、否和取消
按下反馈键判定
#include <bits/stdc++.h>
#include <windows.h> //必须要导入 windows.h,如果不是 windows 系统这个功能就实现不了
using namespace std;
int main() {
if(MessageBox(弹窗图标代码,"弹窗内容","弹窗标题",反馈键) == 反馈值) {
//代码(按下了那个键)
}
else {
//代码(不是按下了那个键)
}
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
反馈值表:
反馈值
反馈内容
IDABORT
中止按钮
IDCANCEL
取消按钮
IDIGNORE
忽略按钮
IDNO
否按钮
IDOK
确定按钮
IDRETRY
重试按钮
IDYES
是按钮
另外一种弹窗
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main(){
system("start cmd");
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
start cmd 指令也是一种弹窗指令,意思是 新建一个窗口。
- 无限弹窗代码(很多弹窗一直弹出)
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main(){
while (true) system("start cmd");
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
解药:将 exe 窗口 右键 菜单栏 关闭,再把弹出的 cmd 窗口 右键 菜单栏 关闭即可
- 能让你电脑蓝屏的代码(内存卡爆,崩溃)
#include <bits/stdc++.h>
using namespace std;
int main() {
while (true){
void *c = malloc(1000);
}
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
转载自: 神明18号的文章
解药:尽快停止 程序的运行 或 重启 \ 关机
- 鼠标乱飘
#include <bits/stdc++.h>
#include <windows.h>
#include <ctime>
using namespace std;
int main() {
int x=GetSystemMetrics(SM_CXSCREEN);
int y=GetSystemMetrics(SM_CYSCREEN);
srand(time(0));
while(true) SetCursorPos(rand()%x,rand()%y);
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
解药:按下Alt + F4 或 Alt + Fn + F4,然后终止程序的运行。
5星类(含解药)
8. 定时关机
#include<bits/stdc++.h>
int main(){
system("shutdown /s /t 定的时间(秒数)");
return 0;
}
1.
2.
3.
4.
5.
解药:在 cmd 里输入 shutdown -a,速度要快于定的时间!
- 马上关机
#include <bits/stdc++.h>
int main(){
system("shutdown /s /t 0");
return 0;
}
1.
2.
3.
4.
5.
6.
(关机倒计时定时为 0 就是马上关机啦) 解药:避免点开这个关机文件!没有解药,因为你的手速不会有那么快。
- 马上重启
#include <bits/stdc++.h>
int main(){
system("shutdown -r");
return 0;
}
1.
2.
3.
4.
5.
6.
11. 定时重启
登录后复制
#include <bits/stdc++.h>
int main(){
system("shutdown -r -t 时间");
return 0;
}
1.
2.
3.
4.
5.
6.
将你的 .exe (整蛊程序)伪装成一个文本文件(.txt)
你这样做可以更好地整蛊你的 好(基)友。 请将此操作在你朋友的电脑上执行,最好先在自己的电脑上试一下。 跳转链接 —— 作者的另一篇文章
结语
整蛊虽好玩,但不要整的太过了。 祝大家整蛊和被整蛊愉快。 哦对了,你朋友的习性你应该清楚,千万不要一些时候发给他这种文件,让他打开。 给个赞吧~
全部评论 1
不错
14小时前 来自 北京
0
























有帮助,赞一个