源代码:
#include <stdio.h>
#include <iostream>
#include <conio.h>
#define maxn 1010
using namespace std;
int main(){
int n,a[maxn],b[maxn],read;
int kase = 0;
cout << "Please choice the mode:"<<endl;
cout << "1-classical"<<endl;
cout << "2-simple"<<endl;
cout << "3-Buliding now......"<<endl;
cout << "Other input-break"<<endl;
read = getch();
if (read == 1);
else if (read == 2)cout << "Building now ......"<<endl;
else if (read == 3)cout << "Building now ......"<<endl;
else return 0;
cout << "Please input number of number:"<<endl;
while (cin>>n &&n){
cout << "Game "<<++kase <<":"<<endl;
cout << "Please input the answer("<<n<<" 1-9 number)"<<endl;
for (int i = 0;i<n;i++)cin>>a[i];
for (int i = 0;i<1000;i++)cout<<endl;
for (;;){
int A = 0,B = 0;
for (int i = 0;i < n;i++){
cin>>b[i];
if (a[i]==b[i])A++;
}
if (b[0] == 0) break;
for (int d = 1;d <=9;d++){
int c1=0,c2=0;
for (int i = 0;i < n; i++){
if (a[i]== d)c1++;
if (b[i]== d)c2++;
}
if (c1<c2) B +=c1;else B +=c2;
}
cout <<"\t("<<A<<","<<B-A<<")"<<endl;
}
}
return 0;
}
但是read = getch();这一行命令出了问题,我输入后控制台没有做出任何反应。可是按照常规来说不是应该读取成功,然后进行下一行命令的吗?