-
个人简介
纯手搓内容
Java1.21.11超平坦 -1147546712050017
82 -59 403
充能
#include<iostream> #include<windows.h> #include<vector> #include<ctime> using namespace std; short win,x,y,what,his,a[6]={5,-1,1,0,2,1}; bool I,he; string s[6]={"大招","充能","单枪","盾","双枪","二级盾"}; void print(string s){short len=s.size();for(short i=0;i<len;i++){cout<<s[i];Sleep(25);}} void look(){Sleep(1000);system("cls");} void start(){system("mode con cols=28 lines=10");system("color 0E");} void wl(bool q){ system("mode con cols=18 lines=11"); cout<<"\n\n\n\n "; if(q){system("color 4F"); cout<<" WIN";} else{system("color 7F");cout<<"GAME OVER";} cout<<endl; look(); start(); } int main() { srand(time(0)); CONSOLE_CURSOR_INFO info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&info); start(); while(true){ I=he=true; x=y=0; while(I&&he){ printf("我的能量:%d \t对方能量:%d\n",x,y); for(short j=0;j<6;j++) if(a[j]<=x)cout<<j<<':'<<s[j]<<" 消耗"<<a[j]<<"能量"<<endl; cout<<"选一项:";cin>>what; if(x<a[what]||what>5){cout<<"你配吗?能量自爆!";I=0;look();break;} if(y==5)his=0; else if(y==0&&x==0)his=1; else{ vector<short> h; h.push_back(1); h.push_back(3); if(y>=1) h.push_back(2),h.push_back(5); if(y>=2) h.push_back(4); his=h[rand()%h.size()]; } x-=a[what]; y-=a[his]; cout<<"你用了"<<s[what]<<"对方用了"<<s[his]; if(what!=his){ cout<<endl; if(what==0)he=false; else if(his==0)I=false; else if(what==4&&his!=5)he=false; else if(his==4&&what!=5)I=false; else if(what==2&&his==1)he=false; else if(his==2&&what==1)I=false; } look(); } if(!he){wl(1);win++;} if(!I)wl(0); } }塔防
#include <iostream> #include <windows.h> #include <string> #include <conio.h> #include <algorithm> #include <time.h> #define S(c) system(c); #define Set(c) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|(c)) #define R FOREGROUND_RED #define B FOREGROUND_BLUE #define G FOREGROUND_GREEN using namespace std; const short L=10,C=40; HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO info={1,0}; string a[L]; short T,d=250,x=4,g[L]={6,6,6,6,6,6,6,6,6,6}; void pos(int x,int y) {COORD Pos={x,y}; SetConsoleCursorPosition(H,Pos);} void cp(short a,string s) { switch (a) { case 0: Set(R|B|G); break; case 1: Set(R|B); break; case 2: Set(B); break; case 3: Set(B|G); break; case 4: Set(G); break; case 5: Set(R|G); break; case 6: Set(R); break; } cout<<s; } bool Game() { int s=0; for (short i=0;i<L;i++) if (g[i]>1) {s++; if (s>=3) return true;} return false; } int main() { SetConsoleCursorInfo(H,&info); S("color F0"); cout<<"\n\t\t\t\t\t游戏规则:\n"; cout<<"\t 保护所有行的生命值(右侧敌人 ),避免70%生命的命值归 0。"; cout<<"\n\t 使用↑和↓控制<在10行之间切换,选中你要操作的行。"; cout<<"\n\t 选中目标行后,按空格攻击,会攻击该行最右侧的敌人"; cout<<"\n\t 敌人开始,降低其强度(颜色变浅),直到敌人消失。"; cout<<"\n\t 当敌人到每行最右边时,会根据敌人强度削减对应行的生命值。"; cout<<"\n\t 共250发子弹,节约使用。Q键暂停,任意键继续\n\t\t"; S("pause"); S("mode con cols=87 lines=12"); S("color 0F"); for (int i=0;i<L;i++) for (int j=0;j<C;j++) a[i]=a[i]+"0"; time_t start=time(NULL); srand(start); while (Game()) { pos(0,0); time_t t=time(NULL); T++; cp(3," "); cout<<" 第 "<<t-start<<" 秒 \t子弹:"<<d<<"发\t\t\t 危险值对应的颜色:"; for (short i=6;i;i--) cp(i," "),cout<<i<<' '; if (T==20) { T=0; short BX=rand()%L; if (g[BX]) a[BX][0]+=rand()%6+1; } for (short i=0;i<L;i++) { cout<<endl; for (short j=0;j<C;j++) if (a[i][j]>'0') cp(a[i][j]-'0',"●"); else cp(0," "); if (i==x) cp(0,"<"); else cp(0," "); if (g[i]>0) {cp(7-g[i],"| ("); cout<<g[i]<<')';} else cp(6,"| ( )"); } for (short i=0;i<L;i++) { if (a[i][C-1]>'0') g[i]-=(a[i][C-1]-'0'); a[i]="0"+a[i].erase(C-1,1); } if (_kbhit()) { char k=_getch(); if (k==72&&x>0) x--; if (k==80&&x<L-1) x++; if (k=='Q'||k=='q') { S("cls"); S("pause"); } if (k==' '&&d>0) { d--; for (int i=C*2-2;i>=0;i--) pos(i,x+1),cp(6,"--"); for (short i=C-1;i>=0;i--) if (a[x][i]>'0') {a[x][i]--; break;} } } } S("cls"); Set(R); cout<<"\n\n\n\t\t游戏结束\n\t 成绩:"<<(time(NULL)-start)*1.0<<"秒"; } -
通过的题目
-
最近活动
This person is lazy and didn't join any contests or homework. -
最近编写的题解
This person is lazy and didn't write any solutions.