|
|
вернуться в форумWA #1 C++ Послано Panzer 12 дек 2010 01:00 Why I have WA? On my computer everything is ok... Please Help. Code: #include <cstdlib> #include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { int n;
scanf("%d", &n);
string *tab = new string [n*2];
//-------------------INPUT------------------------
for(int i=0; i<n*2; i++){ getline(cin, tab[i]); }
string *list = new string [n+7];
//------------------Slytherin----------------------- int pos=0; //pos - position list[pos]="Slytherin:";
for(int i=0; i<n*2; i+=2){ if(tab[i+1][0]=='S'){ pos++; list[pos]=tab[i]; } } pos++; //------------------Hufflepuff----------------------- pos++; list[pos]="Hufflepuff:";
for(int i=0; i<n*2; i+=2){ if(tab[i+1][0]=='H'){ pos++; list[pos]=tab[i]; } } pos++; //------------------Gryffindor----------------------- pos++; list[pos]="Gryffindor:";
for(int i=0; i<n*2; i+=2){ if(tab[i+1][0]=='G'){ pos++; list[pos]=tab[i]; } } pos++; //------------------Ravenclaw----------------------- pos++; list[pos]="Ravenclaw:";
for(int i=0; i<n*2; i+=2){ if(tab[i+1][0]=='R'){ pos++; list[pos]=tab[i]; } }
//-------------------OUTPUT---------------------------
for(int i=0; i<n+7; i++){ cout << list[i] << endl; }
delete [] tab; delete [] list;
system("pause"); return EXIT_SUCCESS; } |
|
|