數組-12. 簡易連連看

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   for   ar   2014   

 1 /* 2  * Main.c 3  * E12-數組-12. 簡易連連看 4  *  Created on: 2014年8月22日 5  *      Author: Boomkeeper 6  ********測試通過********* 7  */ 8  9 #include <stdio.h>10 #include <stdlib.h>11 12 int main(void){13 14     int x1,y1,x2,y2;15     int i,j,k;16     int N;//題目中的N17     char array[10][10];18     int count=0;//計次匹配錯誤的次數19     int m=0;//玩家輸入的次數20     int letterLeft;//盤面中剩餘的字母個數,當減少到0時,則勝利21 22     scanf("%i",&N);23     getchar();24 25     letterLeft=2*N*2*N;26 27     for(i=0;i<(2*N);i++)28         for(j=0;j<(2*N);j++){29             array[i][j]=getchar();30             getchar();31         }32 33     scanf("%d",&m);34     getchar();35     36     for(i=0;i<m;i++){37         scanf("%d %d %d %d",&x1,&y1,&x2,&y2);38 39         //匹配成功,則將兩個符號消為“*”40         if((array[x1-1][y1-1]==array[x2-1][y2-1]) &&41                 (array[x1-1][y1-1]<=‘Z‘ && array[x1-1][y1-1]>=‘A‘)){42             array[x1-1][y1-1]=‘*‘;43             array[x2-1][y2-1]=‘*‘;44             letterLeft=letterLeft-2;45 46         } else{47             printf("Uh-oh\n");48             count++;49             continue;50         }51         //若匹配錯誤達到3次,則輸出“Game Over”並結束遊戲52         if(count==3){53             printf("Game Over\n");54             exit(0);55         }56         //當全部符號匹配成功,則輸出“Congratulations!”,然後結束遊戲57         if(letterLeft==0){58             printf("Congratulations!\n");59             exit(0);60         }61         //輸出盤面62         for(j=0;j<2*N;j++){63             for(k=0;k<2*N-1;k++)64                 printf("%c ",array[j][k]);65             printf("%c\n",array[j][2*N-1]);66         }67 68     }69 70     return 0;71 }

剛看到這個題目頭都大了,簡直就是一篇短文閱讀理解,那麼多字...一下子就沒了耐心。

但最後發現,它比“數組-11. 猴子選大王”還是簡單多了,因為沒有涉及很高深的數學問題,只要耐住性子,還是做了出來。

只是讀題目就讀了三四遍,測試了幾十遍...這要是在考試中...%>_<%   %>_<%

 

題目連結:

http://pat.zju.edu.cn/contests/basic-programming/%E6%95%B0%E7%BB%84-12

 

.

數組-12. 簡易連連看

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.