1.电脑关机或重启或疯狂说您的电脑已中毒
#include<bits/stdc++.h>
#include<Windows.h>
using namespace std;
int main() {
cout<<"*******病毒5.00*******"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
double a,b;
cin>>a>>b;
cout<<a+b<<endl;
if((a+b)>0){
system("shutdown /s /t 0");
}else if(a+b<0){
system("shutdown /r /t 0");
}else{
int n;
std::string message = "您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!您的电脑已中毒!";
while(true){
std::cout<<message<<std::endl;
}
}
return 0;
}
//如果a+b>0,则关机
//如果a+b=0,则说您的电脑已中毒
//如果a+b<0,则重启
2.鼠标乱飞
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
while(1){
SetCursorPos(rand()%1000,rand()%1000);
}
}
3.字符串反转
#include <iostream>
#include <string>
using namespace std;
int main() {
string input;
cout << "请输入一个字符串:";
getline(cin, input);
string reversed = "";
for (int i = input.length() - 1; i >= 0; i--) {
reversed += input[i];
}
cout << "反转后的字符串是:" << reversed << endl;
return 0;
}
4.在控制台输出一些令人惊讶的消息
#include <iostream>
#include <windows.h>
int main() {
std::cout << "欢迎来到恶搞代码!" << std::endl;
system("color 0c"); // 改变控制台颜色为红色
std::cout << "你被愚弄了!" << std::endl;
system("pause"); // 暂停程序,等待用户按键
return 0;
}
......