|
|
вернуться в форумTEST #3 Here is the code(c++), what is wrong? #include <iostream> #include <string> using namespace std; int main() { string name[1001]; int counter=0; int n,i=0; cin>>n; while(i<=n) { getline(cin,name[i]); if(i!=0) if(name[i-1][0]!=name[i][0]) if(name[i-1][0] == 'A' || name[i-1][0] == 'P'||name[i-1][0] == 'O'||name[i-1][0] == 'R') { if(name[i][0] == 'B' || name[i][0] == 'M'||name[i][0] == 'S') counter++; else counter+=2; } else if(name[i-1][0] == 'B' || name[i-1][0] == 'M'||name[i-1][0] == 'S') { counter++; } else if(name[i-1][0] == 'D' || name[i-1][0] == 'G'||name[i-1][0] == 'J'||name[i-1][0] == 'K'||name[i-1][0] == 'T'||name[i-1][0] == 'W') { if(name[i][0] == 'B' || name[i][0] == 'M'||name[i][0] == 'S') counter++; else counter+=2; } i++; } cout<<counter; } Re: TEST #3 Use a map instead of many "if"s. |
|
|