#include<bits/stdc++.h> #include<windows.h> #include<conio.h>//getch _kbhit #include<ctime>//time(0) #include<cstdlib>//rand #define getsb GetCursorPos//POINT #define setsb SetCursorPos #define color(c) HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(handle, c); #define setgb(x,y) COORD pos = {x, y};HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOut, pos); #define cls system("cls"); #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,b,a) for(int i=b-1;i>=a;i--) using namespace std; /* int main(){ for(int i=0;i<16;i++){ // cout<<i; for(int j=0;j<16;j++){ color(i*16+j); printf("%3d",i*16+j); } setgb(0,i+1); } int t=1000; while(t--){ POINT q; Sleep(1000); } } //*/ /* int main(){ srand(time(0)); while(true){ setgb(rand()%120,rand()%30); color(rand()%16); cout<<(char)(rand()%94+33);//33 ~ 126 // Sleep(10); } } //*/ ///* int x,y;int O=0; char c[10000000]={'\0'};int o=-1; struct Dt{//地图 int x,y; int c; char f=' '; void out(){ cout<<f; } void o__(){ c--; if(c==0){ c=1; setgb(x,y); cout<<' '; f=' '; } } }dt[120][50]; void O__(){ // 微调循环匹配数组 只改数字,不改逻辑 for(int i=0;i<120;i++){ for(int j=0;j<50;j++){ dt[i][j].o__(); } } } void zhengchang(){ system("cls"); char f; int kg=0;bool b=1; for(int i=0;i<=o;i++){ switch(c[i]){ case 13:cout<<endl;break; case 9:cout<<" ";break; default:cout<<c[i];break; } } while(1){ Sleep(100); f=getch(); // cout<<(int)f<<endl;//esc=27 switch(f){ case 27:return; case 13:c[++o]=f;cout<<endl;break; case 9:c[++o]=f;cout<<" ";break; case 8:{ if(c[o]==9){ c[o--]='\0'; printf("\b\b\b\b"); break; } c[o--]='\0'; printf("\b \b"); break; } default:c[++o]=f;cout<<f;break; } } } void daimayv(){ system("cls"); char f; for(int i=0;i<120;++i){ for(int j=0;j<30;j++){ dt[i][j].out(); } cout<<endl; } while(1){ Sleep(10); if(_kbhit()){ f=getch(); // cout<<(int)f<<endl;//esc=27 9=tab 8=backspace } else f=0; switch(f){ case 0:break; case 27:return; case 13:c[++o]=f;break; case 9:c[++o]=f;break; case 8:c[o--]='\0';break; default:c[++o]=f;break; } switch(c[O]){ case 13:{ int i=rand()%240; for(;i!=x;i=rand()%240); x=i; y=rand()%10; break; } case 9:y+=4;break; case 32:y++;break; default:{ dt[x][y].c=10; dt[x][y++].f=c[O]; break; } } if(c[O++]=='\0')O=0; } } int main(){ for(int i=0;i<120;i++){ for(int j=0;j<50;j++){ dt[i][j].x=i;dt[i][j].y=j; } } srand(time(0)); x=rand()%120; y=rand()%10; system("color 02"); while(true){ zhengchang(); daimayv(); } } //*/
Note.ms
/qohg8o74bnrac01630478eheh