国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

POJ1013稱硬幣

2019-11-08 19:37:40
字體:
來源:轉載
供稿:網友

問題描述:如下圖

程序代碼:/* *問題描述:POJ1013稱硬幣 */ #include <iostream> #include <cstring> using namespace std; char Left[3][7];//天平左邊硬幣 char Right[3][7];//天平右邊硬幣 char result[3][7];//存儲結果 bool IsFake(char c,bool light) {//light為真表示假設假幣為輕,light為假表示假幣為重     for(int i = 0; i<3; ++i)//三次稱量結果,循環3次     {         char *pLeft,*PRight;//指向天平兩邊的字符串         if(light)         {             pLeft = Left[i];             pRight = Right[i];         }         else//如果假設假幣是重的,則把稱量結果左右對換         {             pLeft = Right[i];             pRight = Left[i];         }         switch(result[i][0])         {         case 'u':            if(strchr(pRight,c)==NULL)                return false;            break;         case 'e':            if(strchr(pLeft,c)||strchr(pRight,c))                return false;            break;         case 'd':            if(strchr(pLeft,c)==NULL)                return false;            break;         }     }     return true; } int main() {     int t;//表示有幾組數據     cin>>t;     while(t--)     {         for(int i = 0; i<3; ++i)            cin>> Left[i] >>Right[i] >>result[i];         for(char c= 'A';c<='L';c++)         {             if(IsFake(c,true))             {                 cout<<"Output:"<<endl;                 cout<<c<<" is the counterfeit coin and it is light./n";                 break;             }             else if (IsFake(c,false))             {                 cout<<"Output:"<<endl;                 cout<<c<<" is the counterfeit coin and it is heary./n";                 break;             }         }     }     return 0; }運行結果:


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 余江县| 读书| 东海县| 孟州市| 赫章县| 齐齐哈尔市| 清远市| 亚东县| 富源县| 玛纳斯县| 泸西县| 宁阳县| 德保县| 兴文县| 开江县| 余庆县| 田阳县| 邵阳市| 邵东县| 南靖县| 宜城市| 夏邑县| 泉州市| 临洮县| 久治县| 红原县| 桃园县| 定日县| 吴江市| 新昌县| 汉川市| 桐梓县| 仪征市| 崇明县| 宁河县| 乌审旗| 甘肃省| 石景山区| 合江县| 罗平县| 伊吾县|