国产探花免费观看_亚洲丰满少妇自慰呻吟_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; }運行結果:


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陆川县| 香港| 会东县| 吴桥县| 九江市| 曲麻莱县| 林西县| 宕昌县| 墨脱县| 濮阳市| 固阳县| 清水县| 建湖县| 郴州市| 叙永县| 册亨县| 曲靖市| 尉氏县| 内乡县| 九台市| 霍州市| 昭觉县| 南召县| 开江县| 云和县| 镇坪县| 竹山县| 鱼台县| 三河市| 阳城县| 扎囊县| 句容市| 中西区| 璧山县| 安达市| 泰安市| 无锡市| 枞阳县| 丹江口市| 富川| 襄樊市|