猜數字(?A?B)
#include<iostream>using namespace std ;
int Matrix ,Total = 3;
int main()
{
Matrix = 5 ;
Matrix = 3 ;
Matrix = 2 ;
Matrix = 4 ;
int Temp , A , B ;
while(A!=4)
{
A=0;
B=0;
for(int X=0;X<=Total;X=X+1)
{
cout << "請輸入第" << X+1 << "個數:" ;
cin >> Temp ;
if( Temp == Matrix )
{
A=A+1;
}
for(int Y=0;Y<=Total;Y=Y+1)
{
if( X!=Y && Temp == Matrix )
{
B=B+1;
}
}
}
cout << endl << A << "A" << B << "B" << endl ;
}
cout << "正確了!" << endl ;
system("PAUSE") ;
return 0 ;
}
頁:
[1]

