|
|
вернуться в форумI don't understand why this sol (C++) /////////////////// #include <iostream> using namespace std; int main() { char text[256001]; int i, wbeg=-1; for(i=0;; i++) { cin.get(text[i]);if(cin.eof())break; if(('A'<=text[i] && text[i]<='Z') || ('a'<=text[i] && text[i]<='z')) { if(wbeg==-1) wbeg=i; } else if(wbeg!=-1) { for(int j=wbeg; j<(i-wbeg)/2+wbeg; j++) { char tmp=text[j]; text[j]=text[i-1-j+wbeg]; text[i-1-j+wbeg]=tmp; } wbeg=-1; } } for(int j=0; j<i; j++) cout<<text[j]; return 0; } //////////////////////////// returns WA#10, and this sol //////////////////////////// #include <iostream> using namespace std; int main() { char text[256001]; int i, wbeg=-1; for(i=0; !cin.eof(); i++) { cin.get(text[i]); if(('A'<=text[i] && text[i]<='Z') || ('a'<=text[i] && text[i]<='z')) { if(wbeg==-1) wbeg=i; } else if(wbeg!=-1) { for(int j=wbeg; j<(i-wbeg)/2+wbeg; j++) { char tmp=text[j]; text[j]=text[i-1-j+wbeg]; text[i-1-j+wbeg]=tmp; } wbeg=-1; } } for(int j=0; j<i-1; j++) cout<<text[j]; return 0; } //////////////// returns AC????? I only replaced the !cin.eof condition. I don't understand, what the difference in the running of this programms. They returned the same answers in all of my tests! Edited by author 23.03.2010 01:16 Edited by author 23.03.2010 01:27 hammaga omad ushbu dasturda ahamiyatli joylari bor yani .,?! Shu singari belgilar har bir satrning oxirida kelishi kerak.botir_studio@mail.ru Re: I don't understand Try test where last line do not ends with CR/LF |
|
|