|
|
вернуться в форумfor help ,thanks a lot! #include <iostream> #include <stdlib.h> #include <string> using namespace std; int main() { long length = 0; int answers_count = 0,over, result, total = 0; string str_; while(!(cin>>length) || length > 1000000000) cin.clear(); while(!(cin>>answers_count) || answers_count > 5000) cin.clear(); string **str = new string*[answers_count]; for(int i = 0; i < answers_count; i++) { str[i] = new string[3]; for(int j = 0; j < 3; j++) { cin>>str_; str[i][j] = str_; } } while(cin>>over && over != -1); for(int i = 0; i < answers_count; i++){ int first_pos = atoi(str[i][0].c_str()); int last_pos = atoi(str[i][1].c_str()); result = last_pos - first_pos; if((result+1)%2 == 0 && str[i][2] =="even" || (result+1) % 2!= 0 && str[i][2] =="odd") total++; } cout<<total<<endl; system("pause"); return 0; } sometime it's "wrong answer",sometime it's "complication error",who can analyse it detailed,thanks a lot! |
|
|