找回密碼
 註冊
搜索
熱搜: 活動 交友 discuz
查看: 2044|回覆: 0

[原創] 猜數字(?A?B)

[複製鏈接]
發表於 2007-6-15 11:41:58 | 顯示全部樓層 |閲讀模式
  1. #include<iostream>
  2. using namespace std ;

  3. int Matrix[3] ,Total = 3;

  4. int main()
  5. {
  6.     Matrix[0] = 5 ;
  7.     Matrix[1] = 3 ;
  8.     Matrix[2] = 2 ;
  9.     Matrix[3] = 4 ;

  10.     int Temp[Total] , A , B ;

  11.     while(A!=4)
  12.     {
  13.         A=0;
  14.         B=0;
  15.         for(int X=0;X<=Total;X=X+1)
  16.         {
  17.             cout << "請輸入第" << X+1 << "個數:" ;
  18.             cin >> Temp[X] ;
  19.             if( Temp[X] == Matrix[X] )
  20.             {
  21.                 A=A+1;
  22.             }
  23.             for(int Y=0;Y<=Total;Y=Y+1)
  24.             {
  25.                 if( X!=Y && Temp[X] == Matrix[Y] )
  26.                 {
  27.                     B=B+1;
  28.                 }
  29.             }
  30.         }
  31.         cout << endl << A << "A" << B << "B" << endl ;
  32.     }
  33.     cout << "正確了!" << endl ;  
  34.    
  35.     system("PAUSE") ;
  36.     return 0 ;
  37. }
複製代碼
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Checking the Pageranks

Archiver|手機版|小黑屋|WEO

GMT+8, 2026-7-29 08:38 PM , Processed in 0.021696 second(s), 18 queries .

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表