飞道的博客

历史最长的贪吃蛇!!! 足足写了3天! 食物从天而降, 自动找东西吃,有炸弹减血,随机出现的墙,引入账户机制,会记录消费记录,付费继续游戏,也可切换账户

256人阅读  评论(0)

  
  1. #include<bits/stdc++.h>
  2. #include<setjmp.h>
  3. jmp_buf jmpbuffer;
  4. using namespace std;
  5. const int maxn = 30;
  6. const int maxm = 30;
  7. char maps[ 30][ 30];
  8. int dx[ 4] = { -1, 0, 1, 0};
  9. int dy[ 4] = { 0, -1, 0, 1};
  10. bool boom = false;
  11. bool stop_fall = false;
  12. int blood = 100;
  13. int res;
  14. int cnt = 0;
  15. int speed = 1600000;
  16. string moves;
  17. string nothing;
  18. string oper1 = "为蛇加血量消耗了:";
  19. string oper2 = "为账户充值增加了:";
  20. string oper3 = "为蛇变换头尾消耗了:";
  21. int count_num;
  22. int u;
  23. struct fg {
  24. string codes;
  25. int money;
  26. }ff;
  27. struct ffg {
  28. string operations;
  29. int changes;
  30. int moneys;
  31. };
  32. map< string, fg> kk;
  33. map< string, vector<ffg> > kkk;
  34. string str1, str2, op;
  35. bool need_to_put = true;
  36. int aaa, bbb, aa;
  37. int head, tail;
  38. int num = 0;
  39. int total_num = maxn * maxm;
  40. struct no {
  41. int x;
  42. int y;
  43. int next;
  44. }node[maxn * maxm];
  45. bool IO(char c) {
  46. if(c == 'a') return true;
  47. if(c == 'w') return true;
  48. if(c == 'd') return true;
  49. if(c == 's') return true;
  50. return false;
  51. }
  52. struct bo {
  53. int x;
  54. int y;
  55. }bombs[ 200];
  56. int bombs_num;
  57. int ccc, ddd, cc;
  58. int dist(int i, int j, int x, int y) {
  59. return abs(i - x) + abs(j - y);
  60. }
  61. int swaps(int t) {
  62. if(t == -1 || (node[t].next == -1))
  63. return t;
  64. //蛇头蛇尾互换,但返回值有wen'ti
  65. else {
  66. int tt = swaps(node[t].next);
  67. node[node[t].next].next = t;
  68. node[t].next = -1;
  69. return tt;
  70. }
  71. }
  72. bool lk = true;
  73. int main() {
  74. while( 1) {
  75. if(setjmp(jmpbuffer) != 0) {}
  76. cout << "请输入账户:";
  77. cin >> str1;
  78. if(!kk.count(str1)) {
  79. cout << "该用户不存在,请注册" << endl;
  80. cout << "请输入账户:";
  81. cin >> str1;
  82. if(kk.count(str1)) {
  83. cout << "该账户已经存在!" << endl;
  84. goto ppp;
  85. }
  86. cout << "请输入密码:";
  87. cin >> str2;
  88. cout << "请输入充值点数:";
  89. lk = false;
  90. int u;
  91. cin >> u;
  92. kk[str1].codes = str2;
  93. kk[str1].money = u;
  94. kkk[str1].push_back({oper2, u, kk[str1].money});
  95. cout << "账户" << str1 << "的花费记录" << endl;
  96. for( int i = 0; i < kkk[str1].size(); i ++) {
  97. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  98. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  99. }
  100. cout << "按1继续" << endl;
  101. cin >> nothing;
  102. }
  103. else {
  104. ppp:
  105. cout << "请输入密码:";
  106. cin >> str2;
  107. }
  108. while(kk[str1].codes != str2) {
  109. cout << "密码错误" << endl;
  110. cout << "按1再次输入密码, 按2重新注册" << endl;
  111. while( cin >> op) {
  112. if(op[ 0] != '1' && op[ 0] != '2') continue;
  113. else break;
  114. }
  115. if(op[ 0] == '1') {
  116. cout << "请输入密码:";
  117. cin >> str2;
  118. continue;
  119. }
  120. else if(op[ 0] == '2') {
  121. cout << "请输入账户:";
  122. cin >> str1;
  123. if(kk.count(str1)) {
  124. cout << "该账户已经存在!" << endl;
  125. goto ppp;
  126. }
  127. cout << "请输入密码:";
  128. cin >> str2;
  129. cout << "请输入充值点数:";
  130. int u;
  131. cin >> u;
  132. kk[str1].codes = str2;
  133. kk[str1].money = u;
  134. kkk[str1].push_back({oper2, u, kk[str1].money});
  135. cout << "账户" << str1 << "的花费记录" << endl;
  136. for( int i = 0; i < kkk[str1].size(); i ++) {
  137. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  138. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  139. }
  140. cout << "按1继续" << endl;
  141. cin >> nothing;
  142. break;
  143. }
  144. }
  145. if( 1 == 1) { // games1();
  146. node[++ num].next = -1;
  147. node[num].x = 5;
  148. node[num].y = 6;
  149. head = num; tail = num;
  150. maps[ 5][ 6] = 'h';
  151. if( 1 == 1) { // puts_one();
  152. while( 1) {
  153. aaa = 1, bbb = rand() * 37 % maxm;
  154. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  155. continue;
  156. if(maps[aaa][bbb] == 'o') continue;
  157. if(maps[aaa][bbb] == 'h') continue;
  158. if(maps[aaa][bbb] == 'w') continue;
  159. maps[aaa][bbb] = 'm';
  160. break;
  161. }
  162. need_to_put = false;
  163. }
  164. if( 1 == 1) { //outs();
  165. for( int i = 0; i < maxn; i ++) {
  166. for( int j = 0; j < maxm; j ++) {
  167. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  168. maps[i][j] = '#';
  169. cout << maps[i][j];
  170. continue;
  171. }
  172. cout << maps[i][j];
  173. }
  174. cout << endl;
  175. }
  176. }
  177. while( 1) {
  178. if( 1 == 1) { // works()
  179. int dis = 0x3f, pos = -1;
  180. int xx = node[head].x, yy = node[head].y;
  181. for( int k = 0; k < 4; k ++) {
  182. int xxx = xx + dx[k], yyy = yy + dy[k];
  183. if(xxx == 0 || xxx == maxn - 1 || yyy == 0 || yyy == maxm - 1)
  184. continue;
  185. if(maps[xxx][yyy] == 'o') continue;
  186. if(maps[xxx][yyy] == 'w') continue;
  187. if(maps[xxx][yyy] == 'b') continue;
  188. if(dist(xxx, yyy, aaa, bbb) < dis) {
  189. dis = dist(xxx, yyy, aaa, bbb);
  190. pos = k;
  191. }
  192. }
  193. if(pos == -1) {
  194. cout << "it is time to swap the tail and head" << endl;
  195. cout << "是否为这条蛇续命;按1继续,且至少充1000金币,按2就只能重新开始了" << endl;
  196. cin >> u;
  197. if(u == 2) {
  198. bombs_num = 0;
  199. memset(maps, ' ', sizeof(maps));
  200. num = 0;
  201. blood = 100;
  202. node[++ num].next = -1;
  203. node[num].x = 5;
  204. node[num].y = 6;
  205. speed = 16000000;
  206. head = num; tail = num;
  207. maps[ 5][ 6] = 'h';
  208. if( 1 == 1) { // puts_one();
  209. while( 1) {
  210. aaa = 1, bbb = rand() * 37 % maxm;
  211. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  212. continue;
  213. if(maps[aaa][bbb] == 'o') continue;
  214. if(maps[aaa][bbb] == 'h') continue;
  215. if(maps[aaa][bbb] == 'w') continue;
  216. maps[aaa][bbb] = 'm';
  217. break;
  218. }
  219. need_to_put = false;
  220. }
  221. if( 1 == 1) { //outs();
  222. for( int i = 0; i < maxn; i ++) {
  223. for( int j = 0; j < maxm; j ++) {
  224. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  225. maps[i][j] = '#';
  226. cout << maps[i][j];
  227. continue;
  228. }
  229. cout << maps[i][j];
  230. }
  231. cout << endl;
  232. }
  233. }
  234. boom = false;
  235. }
  236. else if(u == 1) {
  237. int uu;
  238. while( 1) {
  239. cout << "请输入充血量值的点数:";
  240. cin >> u;
  241. while(u < 1000) {
  242. cout << "金币少于1000,请再次输入合法的值" << endl;
  243. cin >> u;
  244. }
  245. while(u > kk[str1].money) {
  246. cout << "余额不足哎" << endl;
  247. cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
  248. cin >> u;
  249. if(u == 1) {
  250. cout << "请输入向账户增加的值数" << endl;
  251. int uu;
  252. cin >> uu;
  253. kk[str1].money += uu;
  254. kkk[str1].push_back({oper2, uu, kk[str1].money});
  255. u = 2;
  256. }
  257. if(u == 2) {
  258. cout << "请输入首尾变换的费用" << endl;
  259. cin >> u;
  260. while(u < 1000) {
  261. cout << "金币少于1000,请再次输入合法的值" << endl;
  262. cin >> u;
  263. }
  264. if(u > kk[str1].money) continue;
  265. else
  266. break;
  267. }
  268. }
  269. cout << "蛇可以首尾交换了" << endl;
  270. kk[str1].money -= u;
  271. boom = false;
  272. kkk[str1].push_back({oper3, u, kk[str1].money});
  273. cout << "账户" << str1 << "的花费记录" << endl;
  274. for( int i = 0; i < kkk[str1].size(); i ++) {
  275. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  276. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  277. }
  278. cout << "按1继续" << endl;
  279. cin >> nothing;
  280. break;
  281. }
  282. head = tail;
  283. tail = swaps(tail);
  284. maps[node[head].x][node[head].y] = 'h';
  285. maps[node[tail].x][node[tail].y] = 'o';
  286. int dis = 0x3f, pos = -1;
  287. int xx = node[head].x, yy = node[head].y;
  288. for( int k = 0; k < 4; k ++) {
  289. int xxx = xx + dx[k], yyy = yy + dy[k];
  290. if(xxx == 0 || xxx == maxn - 1 || yyy == 0 || yyy == maxm - 1)
  291. continue;
  292. if(maps[xxx][yyy] == 'o') continue;
  293. if(maps[xxx][yyy] == 'w') continue;
  294. if(dist(xxx, yyy, aaa, bbb) < dis) {
  295. dis = dist(xxx, yyy, aaa, bbb);
  296. pos = k;
  297. }
  298. }
  299. }
  300. }
  301. if(pos == 0) { //work('w');
  302. if( 1 == 1) {
  303. char c; c = 'w';
  304. res ++;
  305. int uio = speed;
  306. if(res % 300 == 299) {
  307. cout << "是否需要变速:";
  308. cout << "按0原样继续,1慢速,2中速,3快速" << endl;
  309. cin >> speed;
  310. }
  311. if(speed == 0) speed = uio;
  312. else if(speed == 1) speed = 160000000;
  313. else if(speed == 2) speed = 16000000;
  314. else if(speed == 3) speed = 1600000;
  315. for( int ik = 0; ik < speed; ik ++) {} // 降速
  316. if( 1 == 1) { // head_move(c);
  317. char temp; temp = c;
  318. cnt ++;
  319. cout << cnt << endl;
  320. int x = node[head].x, y = node[head].y;
  321. if(temp == 'a') y --;
  322. if(temp == 'd') y ++;
  323. if(temp == 'w') x --;
  324. if(temp == 's') x ++;
  325. if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
  326. if(!boom) {
  327. if(x == aaa && y == bbb) {
  328. num ++;
  329. num = num % total_num;
  330. // num 有越界的危险,故%,不影响结果
  331. node[num].x = x;
  332. node[num].y = y;
  333. node[num].next = -1;
  334. node[head].next = num;
  335. maps[node[head].x][node[head].y] = 'o';
  336. head = node[head].next;
  337. maps[node[head].x][node[head].y] = 'h';
  338. aaa = -1; bbb = -1;
  339. need_to_put = true;
  340. stop_fall = false;
  341. }
  342. else {
  343. if(maps[x][y] == 'o') boom = true;
  344. if(!boom) {
  345. num ++;
  346. num = num % total_num;
  347. node[num].x = x;
  348. node[num].y = y;
  349. node[num].next = -1;
  350. node[head].next = num;
  351. maps[node[tail].x][node[tail].y] = ' ';
  352. if(tail != head)
  353. maps[node[head].x][node[head].y] = 'o';
  354. tail = node[tail].next;
  355. head = node[head].next;
  356. maps[node[head].x][node[head].y] = 'h';
  357. }
  358. }
  359. }
  360. }
  361. if( 1 == 1) { // stone_move
  362. aa = aaa - 1;
  363. if(aaa < maxn - 2 && !stop_fall) {
  364. maps[aaa][bbb] = ' ';
  365. aa ++; aaa ++;
  366. }
  367. if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
  368. need_to_put = true;
  369. //return;
  370. }
  371. else if(maps[aaa][bbb] == 'w') {
  372. maps[aa][bbb] = 'm';
  373. aaa = aa;
  374. stop_fall = true;
  375. }
  376. else
  377. maps[aaa][bbb] = 'm';
  378. }
  379. for( int io = 0; io < bombs_num; io ++) {
  380. //bomb_fall_one(io);
  381. int i = io;
  382. int ccc = bombs[i].x, ddd = bombs[i].y;
  383. if(!ccc && !ddd) continue;
  384. if(ccc < maxn - 1) {
  385. maps[ccc][ddd] = ' ';
  386. ccc ++;
  387. bombs[i].x ++;
  388. }
  389. char temps = maps[ccc][ddd];
  390. if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
  391. if( 1 == 1) { //bomb_boom(i);
  392. int ccc = bombs[i].x, ddd = bombs[i].y;
  393. cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
  394. for( int id = ccc - 1; id <= ccc + 1; id ++) {
  395. for( int jd = ddd - 1; jd <= ddd + 1; jd ++) {
  396. if(maps[id][jd] == '#') continue;
  397. if(maps[id][jd] == 'w') maps[id][jd] = ' ';
  398. if(maps[id][jd] == 'm') {
  399. maps[id][jd] = ' ';
  400. //need_to_put = true;
  401. }
  402. if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
  403. blood -= 10;
  404. cout << "the blood of the snake has deleted 10!" << endl;
  405. cout << "蛇剩下的血量为:" << blood << endl;
  406. }
  407. }
  408. }
  409. bombs[i].x = 0, bombs[i].y = 0;
  410. }
  411. //return;
  412. }
  413. else
  414. maps[ccc][ddd] = 'b';
  415. }
  416. if(res % 57 == 1) {
  417. while( 1) {
  418. int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
  419. char temps = maps[fx][fy];
  420. if(temps == 'm' || temps == 'h' || temps == 'o')
  421. continue;
  422. if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
  423. continue;
  424. maps[fx][fy] = 'w';
  425. break;
  426. }
  427. }
  428. if(res % 10 == 1) {
  429. int fx, fy;
  430. while( 1) {
  431. fx = 1, fy = rand() * 57 % maxm;
  432. if(fy == 0 || fy == maxm - 1)
  433. continue;
  434. if(maps[fx][fy] == 'o') continue;
  435. if(maps[fx][fy] == 'h') continue;
  436. if(maps[fx][fy] == 'w') continue;
  437. if(maps[fx][fy] == 'm') continue;
  438. break;
  439. }
  440. maps[fx][fy] = 'b';
  441. bombs[bombs_num].x = fx;
  442. bombs[bombs_num].y = fy;
  443. bombs_num ++;
  444. }
  445. if(blood <= 0) boom = true;
  446. if(boom) {
  447. cout << "game over" << endl;
  448. cout << str1 << " " << str2 << endl;
  449. cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
  450. cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
  451. cin >> u;
  452. if(u == 3) {
  453. bombs_num = 0;
  454. memset(maps, ' ', sizeof(maps));
  455. blood = 100;
  456. speed = 16000000;
  457. head = num; tail = num;
  458. boom = false;
  459. longjmp(jmpbuffer, 1);
  460. }
  461. if(u == 2) {
  462. bombs_num = 0;
  463. memset(maps, ' ', sizeof(maps));
  464. num = 0;
  465. blood = 100;
  466. node[++ num].next = -1;
  467. node[num].x = 5;
  468. node[num].y = 6;
  469. speed = 16000000;
  470. head = num; tail = num;
  471. maps[ 5][ 6] = 'h';
  472. if( 1 == 1) { //puts_one();
  473. while( 1) {
  474. aaa = 1, bbb = rand() * 37 % maxm;
  475. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  476. continue;
  477. if(maps[aaa][bbb] == 'o') continue;
  478. if(maps[aaa][bbb] == 'h') continue;
  479. if(maps[aaa][bbb] == 'w') continue;
  480. maps[aaa][bbb] = 'm';
  481. break;
  482. }
  483. need_to_put = false;
  484. }
  485. if( 1 == 1) { //outs();
  486. for( int i = 0; i < maxn; i ++) {
  487. for( int j = 0; j < maxm; j ++) {
  488. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  489. maps[i][j] = '#';
  490. cout << maps[i][j];
  491. continue;
  492. }
  493. cout << maps[i][j];
  494. }
  495. cout << endl;
  496. }
  497. }
  498. boom = false;
  499. }
  500. else if(u == 1) {
  501. int uu;
  502. while( 1) {
  503. cout << "请输入充血量值的点数:";
  504. cin >> u;
  505. while(u > kk[str1].money) {
  506. cout << "余额不足哎" << endl;
  507. cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
  508. cin >> u;
  509. if(u == 1) {
  510. cout << "请输入向账户增加的值数" << endl;
  511. int uu;
  512. cin >> uu;
  513. kk[str1].money += uu;
  514. kkk[str1].push_back({oper2, uu, kk[str1].money});
  515. u = 2;
  516. }
  517. if(u == 2) {
  518. cout << "请输入向蛇增加的值数" << endl;
  519. cin >> u;
  520. if(u > kk[str1].money) continue;
  521. else
  522. break;
  523. }
  524. }
  525. cout << "蛇的血量重新变为:" << " " << u << endl;
  526. kk[str1].money -= u;
  527. blood = u;
  528. boom = false;
  529. kkk[str1].push_back({oper1, u, kk[str1].money});
  530. cout << "账户" << str1 << "的花费记录" << endl;
  531. for( int i = 0; i < kkk[str1].size(); i ++) {
  532. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  533. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  534. }
  535. cout << "按1继续" << endl;
  536. cin >> nothing;
  537. break;
  538. }
  539. }
  540. }
  541. else { // outss();
  542. for( int i = 0; i < maxn; i ++) {
  543. for( int j = 0; j < maxm; j ++) {
  544. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  545. maps[i][j] = '#';
  546. cout << maps[i][j];
  547. continue;
  548. }
  549. cout << maps[i][j];
  550. }
  551. cout << endl;
  552. }
  553. }
  554. if(need_to_put) { //puts_one();
  555. while( 1) {
  556. aaa = 1, bbb = rand() * 37 % maxm;
  557. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  558. continue;
  559. if(maps[aaa][bbb] == 'o') continue;
  560. if(maps[aaa][bbb] == 'h') continue;
  561. if(maps[aaa][bbb] == 'w') continue;
  562. maps[aaa][bbb] = 'm';
  563. break;
  564. }
  565. need_to_put = false;
  566. }
  567. }
  568. }
  569. if(pos == 1) { //work('a');
  570. if( 1 == 1) {
  571. char c; c = 'a';
  572. res ++;
  573. int uio = speed;
  574. if(res % 300 == 299) {
  575. cout << "是否需要变速:";
  576. cout << "按0原样继续,1慢速,2中速,3快速" << endl;
  577. cin >> speed;
  578. }
  579. if(speed == 0) speed = uio;
  580. else if(speed == 1) speed = 160000000;
  581. else if(speed == 2) speed = 16000000;
  582. else if(speed == 3) speed = 1600000;
  583. for( int ik = 0; ik < speed; ik ++) {} // 降速
  584. if( 1 == 1) { // head_move(c);
  585. char temp; temp = c;
  586. cnt ++;
  587. cout << cnt << endl;
  588. int x = node[head].x, y = node[head].y;
  589. if(temp == 'a') y --;
  590. if(temp == 'd') y ++;
  591. if(temp == 'w') x --;
  592. if(temp == 's') x ++;
  593. if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
  594. if(!boom) {
  595. if(x == aaa && y == bbb) {
  596. num ++;
  597. num = num % total_num;
  598. // num 有越界的危险,故%,不影响结果
  599. node[num].x = x;
  600. node[num].y = y;
  601. node[num].next = -1;
  602. node[head].next = num;
  603. maps[node[head].x][node[head].y] = 'o';
  604. head = node[head].next;
  605. maps[node[head].x][node[head].y] = 'h';
  606. aaa = -1; bbb = -1;
  607. need_to_put = true;
  608. stop_fall = false;
  609. }
  610. else {
  611. if(maps[x][y] == 'o') boom = true;
  612. if(!boom) {
  613. num ++;
  614. num = num % total_num;
  615. node[num].x = x;
  616. node[num].y = y;
  617. node[num].next = -1;
  618. node[head].next = num;
  619. maps[node[tail].x][node[tail].y] = ' ';
  620. if(tail != head)
  621. maps[node[head].x][node[head].y] = 'o';
  622. tail = node[tail].next;
  623. head = node[head].next;
  624. maps[node[head].x][node[head].y] = 'h';
  625. }
  626. }
  627. }
  628. }
  629. if( 1 == 1) { // stone_move
  630. aa = aaa - 1;
  631. if(aaa < maxn - 2 && !stop_fall) {
  632. maps[aaa][bbb] = ' ';
  633. aa ++; aaa ++;
  634. }
  635. if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
  636. need_to_put = true;
  637. //return;
  638. }
  639. else if(maps[aaa][bbb] == 'w') {
  640. maps[aa][bbb] = 'm';
  641. aaa = aa;
  642. stop_fall = true;
  643. }
  644. else
  645. maps[aaa][bbb] = 'm';
  646. }
  647. for( int io = 0; io < bombs_num; io ++) {
  648. //bomb_fall_one(io);
  649. int i = io;
  650. int ccc = bombs[i].x, ddd = bombs[i].y;
  651. if(!ccc && !ddd) continue;
  652. if(ccc < maxn - 1) {
  653. maps[ccc][ddd] = ' ';
  654. ccc ++;
  655. bombs[i].x ++;
  656. }
  657. char temps = maps[ccc][ddd];
  658. if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
  659. if( 1 == 1) { //bomb_boom(i);
  660. int ccc = bombs[i].x, ddd = bombs[i].y;
  661. cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
  662. for( int id = ccc - 1; id <= ccc + 1; id ++) {
  663. for( int jd = ddd - 1; jd <= ddd + 1; jd ++) {
  664. if(maps[id][jd] == '#') continue;
  665. if(maps[id][jd] == 'w') maps[id][jd] = ' ';
  666. if(maps[id][jd] == 'm') {
  667. maps[id][jd] = ' ';
  668. //need_to_put = true;
  669. }
  670. if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
  671. blood -= 10;
  672. cout << "the blood of the snake has deleted 10!" << endl;
  673. cout << "蛇剩下的血量为:" << blood << endl;
  674. }
  675. }
  676. }
  677. bombs[i].x = 0, bombs[i].y = 0;
  678. }
  679. //return;
  680. }
  681. else
  682. maps[ccc][ddd] = 'b';
  683. }
  684. if(res % 57 == 1) {
  685. while( 1) {
  686. int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
  687. char temps = maps[fx][fy];
  688. if(temps == 'm' || temps == 'h' || temps == 'o')
  689. continue;
  690. if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
  691. continue;
  692. maps[fx][fy] = 'w';
  693. break;
  694. }
  695. }
  696. if(res % 10 == 1) {
  697. int fx, fy;
  698. while( 1) {
  699. fx = 1, fy = rand() * 57 % maxm;
  700. if(fy == 0 || fy == maxm - 1)
  701. continue;
  702. if(maps[fx][fy] == 'o') continue;
  703. if(maps[fx][fy] == 'h') continue;
  704. if(maps[fx][fy] == 'w') continue;
  705. if(maps[fx][fy] == 'm') continue;
  706. break;
  707. }
  708. maps[fx][fy] = 'b';
  709. bombs[bombs_num].x = fx;
  710. bombs[bombs_num].y = fy;
  711. bombs_num ++;
  712. }
  713. if(blood <= 0) boom = true;
  714. if(boom) {
  715. cout << "game over" << endl;
  716. cout << str1 << " " << str2 << endl;
  717. cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
  718. cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
  719. cin >> u;
  720. if(u == 3) {
  721. bombs_num = 0;
  722. memset(maps, ' ', sizeof(maps));
  723. blood = 100;
  724. speed = 16000000;
  725. head = num; tail = num;
  726. boom = false;
  727. longjmp(jmpbuffer, 1);
  728. }
  729. if(u == 2) {
  730. bombs_num = 0;
  731. memset(maps, ' ', sizeof(maps));
  732. num = 0;
  733. blood = 100;
  734. node[++ num].next = -1;
  735. node[num].x = 5;
  736. node[num].y = 6;
  737. speed = 16000000;
  738. head = num; tail = num;
  739. maps[ 5][ 6] = 'h';
  740. if( 1 == 1) { //puts_one();
  741. while( 1) {
  742. aaa = 1, bbb = rand() * 37 % maxm;
  743. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  744. continue;
  745. if(maps[aaa][bbb] == 'o') continue;
  746. if(maps[aaa][bbb] == 'h') continue;
  747. if(maps[aaa][bbb] == 'w') continue;
  748. maps[aaa][bbb] = 'm';
  749. break;
  750. }
  751. need_to_put = false;
  752. }
  753. if( 1 == 1) { //outs();
  754. for( int i = 0; i < maxn; i ++) {
  755. for( int j = 0; j < maxm; j ++) {
  756. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  757. maps[i][j] = '#';
  758. cout << maps[i][j];
  759. continue;
  760. }
  761. cout << maps[i][j];
  762. }
  763. cout << endl;
  764. }
  765. }
  766. boom = false;
  767. }
  768. else if(u == 1) {
  769. int uu;
  770. while( 1) {
  771. cout << "请输入充血量值的点数:";
  772. cin >> u;
  773. while(u > kk[str1].money) {
  774. cout << "余额不足哎" << endl;
  775. cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
  776. cin >> u;
  777. if(u == 1) {
  778. cout << "请输入向账户增加的值数" << endl;
  779. int uu;
  780. cin >> uu;
  781. kk[str1].money += uu;
  782. kkk[str1].push_back({oper2, uu, kk[str1].money});
  783. u = 2;
  784. }
  785. if(u == 2) {
  786. cout << "请输入向蛇增加的值数" << endl;
  787. cin >> u;
  788. if(u > kk[str1].money) continue;
  789. else
  790. break;
  791. }
  792. }
  793. cout << "蛇的血量重新变为:" << " " << u << endl;
  794. kk[str1].money -= u;
  795. blood = u;
  796. boom = false;
  797. kkk[str1].push_back({oper1, u, kk[str1].money});
  798. cout << "账户" << str1 << "的花费记录" << endl;
  799. for( int i = 0; i < kkk[str1].size(); i ++) {
  800. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  801. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  802. }
  803. cout << "按1继续" << endl;
  804. cin >> nothing;
  805. break;
  806. }
  807. }
  808. }
  809. else { // outss();
  810. for( int i = 0; i < maxn; i ++) {
  811. for( int j = 0; j < maxm; j ++) {
  812. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  813. maps[i][j] = '#';
  814. cout << maps[i][j];
  815. continue;
  816. }
  817. cout << maps[i][j];
  818. }
  819. cout << endl;
  820. }
  821. }
  822. if(need_to_put) { //puts_one();
  823. while( 1) {
  824. aaa = 1, bbb = rand() * 37 % maxm;
  825. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  826. continue;
  827. if(maps[aaa][bbb] == 'o') continue;
  828. if(maps[aaa][bbb] == 'h') continue;
  829. if(maps[aaa][bbb] == 'w') continue;
  830. maps[aaa][bbb] = 'm';
  831. break;
  832. }
  833. need_to_put = false;
  834. }
  835. }
  836. }
  837. if(pos == 2) { //work('s');
  838. if( 1 == 1) {
  839. char c; c = 's';
  840. res ++;
  841. int uio = speed;
  842. if(res % 300 == 299) {
  843. cout << "是否需要变速:";
  844. cout << "按0原样继续,1慢速,2中速,3快速" << endl;
  845. cin >> speed;
  846. }
  847. if(speed == 0) speed = uio;
  848. else if(speed == 1) speed = 160000000;
  849. else if(speed == 2) speed = 16000000;
  850. else if(speed == 3) speed = 1600000;
  851. for( int ik = 0; ik < speed; ik ++) {} // 降速
  852. if( 1 == 1) { // head_move(c);
  853. char temp; temp = c;
  854. cnt ++;
  855. cout << cnt << endl;
  856. int x = node[head].x, y = node[head].y;
  857. if(temp == 'a') y --;
  858. if(temp == 'd') y ++;
  859. if(temp == 'w') x --;
  860. if(temp == 's') x ++;
  861. if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
  862. if(!boom) {
  863. if(x == aaa && y == bbb) {
  864. num ++;
  865. num = num % total_num;
  866. // num 有越界的危险,故%,不影响结果
  867. node[num].x = x;
  868. node[num].y = y;
  869. node[num].next = -1;
  870. node[head].next = num;
  871. maps[node[head].x][node[head].y] = 'o';
  872. head = node[head].next;
  873. maps[node[head].x][node[head].y] = 'h';
  874. aaa = -1; bbb = -1;
  875. need_to_put = true;
  876. stop_fall = false;
  877. }
  878. else {
  879. if(maps[x][y] == 'o') boom = true;
  880. if(!boom) {
  881. num ++;
  882. num = num % total_num;
  883. node[num].x = x;
  884. node[num].y = y;
  885. node[num].next = -1;
  886. node[head].next = num;
  887. maps[node[tail].x][node[tail].y] = ' ';
  888. if(tail != head)
  889. maps[node[head].x][node[head].y] = 'o';
  890. tail = node[tail].next;
  891. head = node[head].next;
  892. maps[node[head].x][node[head].y] = 'h';
  893. }
  894. }
  895. }
  896. }
  897. if( 1 == 1) { // stone_move
  898. aa = aaa - 1;
  899. if(aaa < maxn - 2 && !stop_fall) {
  900. maps[aaa][bbb] = ' ';
  901. aa ++; aaa ++;
  902. }
  903. if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
  904. need_to_put = true;
  905. //return;
  906. }
  907. else if(maps[aaa][bbb] == 'w') {
  908. maps[aa][bbb] = 'm';
  909. aaa = aa;
  910. stop_fall = true;
  911. }
  912. else
  913. maps[aaa][bbb] = 'm';
  914. }
  915. for( int io = 0; io < bombs_num; io ++) {
  916. //bomb_fall_one(io);
  917. int i = io;
  918. int ccc = bombs[i].x, ddd = bombs[i].y;
  919. if(!ccc && !ddd) continue;
  920. if(ccc < maxn - 1) {
  921. maps[ccc][ddd] = ' ';
  922. ccc ++;
  923. bombs[i].x ++;
  924. }
  925. char temps = maps[ccc][ddd];
  926. if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
  927. if( 1 == 1) { //bomb_boom(i);
  928. int ccc = bombs[i].x, ddd = bombs[i].y;
  929. cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
  930. for( int id = ccc - 1; id <= ccc + 1; id ++) {
  931. for( int jd = ddd - 1; jd <= ddd + 1; jd ++) {
  932. if(maps[id][jd] == '#') continue;
  933. if(maps[id][jd] == 'w') maps[id][jd] = ' ';
  934. if(maps[id][jd] == 'm') {
  935. maps[id][jd] = ' ';
  936. //need_to_put = true;
  937. }
  938. if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
  939. blood -= 10;
  940. cout << "the blood of the snake has deleted 10!" << endl;
  941. cout << "蛇剩下的血量为:" << blood << endl;
  942. }
  943. }
  944. }
  945. bombs[i].x = 0, bombs[i].y = 0;
  946. }
  947. //return;
  948. }
  949. else
  950. maps[ccc][ddd] = 'b';
  951. }
  952. if(res % 57 == 1) {
  953. while( 1) {
  954. int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
  955. char temps = maps[fx][fy];
  956. if(temps == 'm' || temps == 'h' || temps == 'o')
  957. continue;
  958. if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
  959. continue;
  960. maps[fx][fy] = 'w';
  961. break;
  962. }
  963. }
  964. if(res % 10 == 1) {
  965. int fx, fy;
  966. while( 1) {
  967. fx = 1, fy = rand() * 57 % maxm;
  968. if(fy == 0 || fy == maxm - 1)
  969. continue;
  970. if(maps[fx][fy] == 'o') continue;
  971. if(maps[fx][fy] == 'h') continue;
  972. if(maps[fx][fy] == 'w') continue;
  973. if(maps[fx][fy] == 'm') continue;
  974. break;
  975. }
  976. maps[fx][fy] = 'b';
  977. bombs[bombs_num].x = fx;
  978. bombs[bombs_num].y = fy;
  979. bombs_num ++;
  980. }
  981. if(blood <= 0) boom = true;
  982. if(boom) {
  983. cout << "game over" << endl;
  984. cout << str1 << " " << str2 << endl;
  985. cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
  986. cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
  987. cin >> u;
  988. if(u == 3) {
  989. bombs_num = 0;
  990. memset(maps, ' ', sizeof(maps));
  991. blood = 100;
  992. speed = 16000000;
  993. head = num; tail = num;
  994. boom = false;
  995. longjmp(jmpbuffer, 1);
  996. }
  997. if(u == 2) {
  998. bombs_num = 0;
  999. memset(maps, ' ', sizeof(maps));
  1000. num = 0;
  1001. blood = 100;
  1002. node[++ num].next = -1;
  1003. node[num].x = 5;
  1004. node[num].y = 6;
  1005. speed = 16000000;
  1006. head = num; tail = num;
  1007. maps[ 5][ 6] = 'h';
  1008. if( 1 == 1) { //puts_one();
  1009. while( 1) {
  1010. aaa = 1, bbb = rand() * 37 % maxm;
  1011. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  1012. continue;
  1013. if(maps[aaa][bbb] == 'o') continue;
  1014. if(maps[aaa][bbb] == 'h') continue;
  1015. if(maps[aaa][bbb] == 'w') continue;
  1016. maps[aaa][bbb] = 'm';
  1017. break;
  1018. }
  1019. need_to_put = false;
  1020. }
  1021. if( 1 == 1) { //outs();
  1022. for( int i = 0; i < maxn; i ++) {
  1023. for( int j = 0; j < maxm; j ++) {
  1024. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  1025. maps[i][j] = '#';
  1026. cout << maps[i][j];
  1027. continue;
  1028. }
  1029. cout << maps[i][j];
  1030. }
  1031. cout << endl;
  1032. }
  1033. }
  1034. boom = false;
  1035. }
  1036. else if(u == 1) {
  1037. int uu;
  1038. while( 1) {
  1039. cout << "请输入充血量值的点数:";
  1040. cin >> u;
  1041. while(u > kk[str1].money) {
  1042. cout << "余额不足哎" << endl;
  1043. cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
  1044. cin >> u;
  1045. if(u == 1) {
  1046. cout << "请输入向账户增加的值数" << endl;
  1047. int uu;
  1048. cin >> uu;
  1049. kk[str1].money += uu;
  1050. kkk[str1].push_back({oper2, uu, kk[str1].money});
  1051. u = 2;
  1052. }
  1053. if(u == 2) {
  1054. cout << "请输入向蛇增加的值数" << endl;
  1055. cin >> u;
  1056. if(u > kk[str1].money) continue;
  1057. else
  1058. break;
  1059. }
  1060. }
  1061. cout << "蛇的血量重新变为:" << " " << u << endl;
  1062. kk[str1].money -= u;
  1063. blood = u;
  1064. boom = false;
  1065. kkk[str1].push_back({oper1, u, kk[str1].money});
  1066. cout << "账户" << str1 << "的花费记录" << endl;
  1067. for( int i = 0; i < kkk[str1].size(); i ++) {
  1068. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  1069. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  1070. }
  1071. cout << "按1继续" << endl;
  1072. cin >> nothing;
  1073. break;
  1074. }
  1075. }
  1076. }
  1077. else { // outss();
  1078. for( int i = 0; i < maxn; i ++) {
  1079. for( int j = 0; j < maxm; j ++) {
  1080. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  1081. maps[i][j] = '#';
  1082. cout << maps[i][j];
  1083. continue;
  1084. }
  1085. cout << maps[i][j];
  1086. }
  1087. cout << endl;
  1088. }
  1089. }
  1090. if(need_to_put) { //puts_one();
  1091. while( 1) {
  1092. aaa = 1, bbb = rand() * 37 % maxm;
  1093. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  1094. continue;
  1095. if(maps[aaa][bbb] == 'o') continue;
  1096. if(maps[aaa][bbb] == 'h') continue;
  1097. if(maps[aaa][bbb] == 'w') continue;
  1098. maps[aaa][bbb] = 'm';
  1099. break;
  1100. }
  1101. need_to_put = false;
  1102. }
  1103. }
  1104. }
  1105. if(pos == 3) { //work('d');
  1106. if( 1 == 1) {
  1107. char c; c = 'd';
  1108. res ++;
  1109. int uio = speed;
  1110. if(res % 300 == 299) {
  1111. cout << "是否需要变速:";
  1112. cout << "按0原样继续,1慢速,2中速,3快速" << endl;
  1113. cin >> speed;
  1114. }
  1115. if(speed == 0) speed = uio;
  1116. else if(speed == 1) speed = 160000000;
  1117. else if(speed == 2) speed = 16000000;
  1118. else if(speed == 3) speed = 1600000;
  1119. for( int ik = 0; ik < speed; ik ++) {} // 降速
  1120. if( 1 == 1) { // head_move(c);
  1121. char temp; temp = c;
  1122. cnt ++;
  1123. cout << cnt << endl;
  1124. int x = node[head].x, y = node[head].y;
  1125. if(temp == 'a') y --;
  1126. if(temp == 'd') y ++;
  1127. if(temp == 'w') x --;
  1128. if(temp == 's') x ++;
  1129. if(x == 0 || x == maxn - 1 || y == 0 || y == maxm - 1) boom = 1;
  1130. if(!boom) {
  1131. if(x == aaa && y == bbb) {
  1132. num ++;
  1133. num = num % total_num;
  1134. // num 有越界的危险,故%,不影响结果
  1135. node[num].x = x;
  1136. node[num].y = y;
  1137. node[num].next = -1;
  1138. node[head].next = num;
  1139. maps[node[head].x][node[head].y] = 'o';
  1140. head = node[head].next;
  1141. maps[node[head].x][node[head].y] = 'h';
  1142. aaa = -1; bbb = -1;
  1143. need_to_put = true;
  1144. stop_fall = false;
  1145. }
  1146. else {
  1147. if(maps[x][y] == 'o') boom = true;
  1148. if(!boom) {
  1149. num ++;
  1150. num = num % total_num;
  1151. node[num].x = x;
  1152. node[num].y = y;
  1153. node[num].next = -1;
  1154. node[head].next = num;
  1155. maps[node[tail].x][node[tail].y] = ' ';
  1156. if(tail != head)
  1157. maps[node[head].x][node[head].y] = 'o';
  1158. tail = node[tail].next;
  1159. head = node[head].next;
  1160. maps[node[head].x][node[head].y] = 'h';
  1161. }
  1162. }
  1163. }
  1164. }
  1165. if( 1 == 1) { // stone_move
  1166. aa = aaa - 1;
  1167. if(aaa < maxn - 2 && !stop_fall) {
  1168. maps[aaa][bbb] = ' ';
  1169. aa ++; aaa ++;
  1170. }
  1171. if(maps[aaa][bbb] == 'o' || maps[aaa][bbb] == 'h') {
  1172. need_to_put = true;
  1173. //return;
  1174. }
  1175. else if(maps[aaa][bbb] == 'w') {
  1176. maps[aa][bbb] = 'm';
  1177. aaa = aa;
  1178. stop_fall = true;
  1179. }
  1180. else
  1181. maps[aaa][bbb] = 'm';
  1182. }
  1183. for( int io = 0; io < bombs_num; io ++) {
  1184. //bomb_fall_one(io);
  1185. int i = io;
  1186. int ccc = bombs[i].x, ddd = bombs[i].y;
  1187. if(!ccc && !ddd) continue;
  1188. if(ccc < maxn - 1) {
  1189. maps[ccc][ddd] = ' ';
  1190. ccc ++;
  1191. bombs[i].x ++;
  1192. }
  1193. char temps = maps[ccc][ddd];
  1194. if(temps == '#' || temps == 'w' || temps == 'o' || temps == 'm' || temps == 'h') {
  1195. if( 1 == 1) { //bomb_boom(i);
  1196. int ccc = bombs[i].x, ddd = bombs[i].y;
  1197. cout << "hjk" << " " << i << " " << ccc << " " << ddd << endl;
  1198. for( int id = ccc - 1; id <= ccc + 1; id ++) {
  1199. for( int jd = ddd - 1; jd <= ddd + 1; jd ++) {
  1200. if(maps[id][jd] == '#') continue;
  1201. if(maps[id][jd] == 'w') maps[id][jd] = ' ';
  1202. if(maps[id][jd] == 'm') {
  1203. maps[id][jd] = ' ';
  1204. //need_to_put = true;
  1205. }
  1206. if(maps[id][jd] == 'o' || maps[id][jd] == 'h') {
  1207. blood -= 10;
  1208. cout << "the blood of the snake has deleted 10!" << endl;
  1209. cout << "蛇剩下的血量为:" << blood << endl;
  1210. }
  1211. }
  1212. }
  1213. bombs[i].x = 0, bombs[i].y = 0;
  1214. }
  1215. //return;
  1216. }
  1217. else
  1218. maps[ccc][ddd] = 'b';
  1219. }
  1220. if(res % 57 == 1) {
  1221. while( 1) {
  1222. int fx = rand() * 18 % maxn, fy = rand() * 18 % maxm;
  1223. char temps = maps[fx][fy];
  1224. if(temps == 'm' || temps == 'h' || temps == 'o')
  1225. continue;
  1226. if(fx == 0 || fx == maxn - 1 || fy == 0 || fy == maxm - 1)
  1227. continue;
  1228. maps[fx][fy] = 'w';
  1229. break;
  1230. }
  1231. }
  1232. if(res % 10 == 1) {
  1233. int fx, fy;
  1234. while( 1) {
  1235. fx = 1, fy = rand() * 57 % maxm;
  1236. if(fy == 0 || fy == maxm - 1)
  1237. continue;
  1238. if(maps[fx][fy] == 'o') continue;
  1239. if(maps[fx][fy] == 'h') continue;
  1240. if(maps[fx][fy] == 'w') continue;
  1241. if(maps[fx][fy] == 'm') continue;
  1242. break;
  1243. }
  1244. maps[fx][fy] = 'b';
  1245. bombs[bombs_num].x = fx;
  1246. bombs[bombs_num].y = fy;
  1247. bombs_num ++;
  1248. }
  1249. if(blood <= 0) boom = true;
  1250. if(boom) {
  1251. cout << "game over" << endl;
  1252. cout << str1 << " " << str2 << endl;
  1253. cout << "是否为这条蛇续命;按1继续,按2就只能重新开始了";
  1254. cout << ",按3重新跳到最初始的输入账户的界面,可以可以更换账户!" << endl;
  1255. cin >> u;
  1256. if(u == 3) {
  1257. bombs_num = 0;
  1258. memset(maps, ' ', sizeof(maps));
  1259. blood = 100;
  1260. speed = 16000000;
  1261. head = num; tail = num;
  1262. boom = false;
  1263. longjmp(jmpbuffer, 1);
  1264. }
  1265. if(u == 2) {
  1266. bombs_num = 0;
  1267. memset(maps, ' ', sizeof(maps));
  1268. num = 0;
  1269. blood = 100;
  1270. node[++ num].next = -1;
  1271. node[num].x = 5;
  1272. node[num].y = 6;
  1273. speed = 16000000;
  1274. head = num; tail = num;
  1275. maps[ 5][ 6] = 'h';
  1276. if( 1 == 1) { //puts_one();
  1277. while( 1) {
  1278. aaa = 1, bbb = rand() * 37 % maxm;
  1279. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  1280. continue;
  1281. if(maps[aaa][bbb] == 'o') continue;
  1282. if(maps[aaa][bbb] == 'h') continue;
  1283. if(maps[aaa][bbb] == 'w') continue;
  1284. maps[aaa][bbb] = 'm';
  1285. break;
  1286. }
  1287. need_to_put = false;
  1288. }
  1289. if( 1 == 1) { //outs();
  1290. for( int i = 0; i < maxn; i ++) {
  1291. for( int j = 0; j < maxm; j ++) {
  1292. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  1293. maps[i][j] = '#';
  1294. cout << maps[i][j];
  1295. continue;
  1296. }
  1297. cout << maps[i][j];
  1298. }
  1299. cout << endl;
  1300. }
  1301. }
  1302. boom = false;
  1303. }
  1304. else if(u == 1) {
  1305. int uu;
  1306. while( 1) {
  1307. cout << "请输入充血量值的点数:";
  1308. cin >> u;
  1309. while(u > kk[str1].money) {
  1310. cout << "余额不足哎" << endl;
  1311. cout << "接下来按1准备向账户充值,2是刚才充值的血量点数" << endl;
  1312. cin >> u;
  1313. if(u == 1) {
  1314. cout << "请输入向账户增加的值数" << endl;
  1315. int uu;
  1316. cin >> uu;
  1317. kk[str1].money += uu;
  1318. kkk[str1].push_back({oper2, uu, kk[str1].money});
  1319. u = 2;
  1320. }
  1321. if(u == 2) {
  1322. cout << "请输入向蛇增加的值数" << endl;
  1323. cin >> u;
  1324. if(u > kk[str1].money) continue;
  1325. else
  1326. break;
  1327. }
  1328. }
  1329. cout << "蛇的血量重新变为:" << " " << u << endl;
  1330. kk[str1].money -= u;
  1331. blood = u;
  1332. boom = false;
  1333. kkk[str1].push_back({oper1, u, kk[str1].money});
  1334. cout << "账户" << str1 << "的花费记录" << endl;
  1335. for( int i = 0; i < kkk[str1].size(); i ++) {
  1336. cout << i + 1 << " " << kkk[str1][i].operations << kkk[str1][i].changes;
  1337. cout << "这个时候账户余额为:" << kkk[str1][i].moneys << endl;
  1338. }
  1339. cout << "按1继续" << endl;
  1340. cin >> nothing;
  1341. break;
  1342. }
  1343. }
  1344. }
  1345. else { // outss();
  1346. for( int i = 0; i < maxn; i ++) {
  1347. for( int j = 0; j < maxm; j ++) {
  1348. if(i == 0 || i == maxn - 1 || j == 0 || j == maxm - 1) {
  1349. maps[i][j] = '#';
  1350. cout << maps[i][j];
  1351. continue;
  1352. }
  1353. cout << maps[i][j];
  1354. }
  1355. cout << endl;
  1356. }
  1357. }
  1358. if(need_to_put) { //puts_one();
  1359. while( 1) {
  1360. aaa = 1, bbb = rand() * 37 % maxm;
  1361. if(aaa == 0 || aaa == maxn - 1 || bbb == 0 || bbb == maxm - 1)
  1362. continue;
  1363. if(maps[aaa][bbb] == 'o') continue;
  1364. if(maps[aaa][bbb] == 'h') continue;
  1365. if(maps[aaa][bbb] == 'w') continue;
  1366. maps[aaa][bbb] = 'm';
  1367. break;
  1368. }
  1369. need_to_put = false;
  1370. }
  1371. }
  1372. }
  1373. }
  1374. }
  1375. }
  1376. }
  1377. return 0;
  1378. }

 


转载:https://blog.csdn.net/cyz3209/article/details/105268072
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场