求高手给讲讲这个程序;
#include <iostream>
using namespace std;
int main()
{ char key[ ]={'a','c','b','a','d'};
char c;
int ques=0,numques=5,numcorrect=0;
cout<<"Enter the "<<numques<<" question tests:"<<endl;
while(cin.get(c))
{ if(c != '\n')
if(c == key[ques])
{ numcorrect++; cout << " "; }
else cout<<"*";
else
{ cout<<" Score "<<float(numcorrect)/numques*100<<"%";
ques = 0;
numcorrect = 0;
cout << endl;
continue;
}
ques++;
}
}
[解决办法]
cin.get()是类库里的一个函数的,不需要定义,只需要在开头加上#include<iostream>就OK了!
[解决办法]