|
|
вернуться в форумwhat wrong?! #include <stdio.h> #include <string.h> #define ulong unsigned long void main () { #ifndef ONLINE_JUDGE freopen("Data.txt","rt",stdin); freopen("Output.txt","wt",stdout); #endif char slogan[1001]; ulong cost=0,i; fgets(slogan,1001,stdin); for(i=0;i<strlen(slogan);++i) { if(slogan[i]>='a'&&slogan[i]<='z') { if((slogan[i]-'a')%3==0) { ++cost; continue; } if((slogan[i]-'a')%3==1) { cost+=2; continue; } cost+=3; continue; } if(slogan[i]==' '||slogan[i]=='.') { ++cost; continue; } if(slogan[i]==',') { cost+=2; continue; } cost+=3; } printf("%lu",cost); } why i get wa1?! Edited by author 28.06.2011 01:33 Re: what wrong?! Ok, i got ac. The thing was that fgets reads also '\n' and handled it as '!', before finish the program. But i don't understand why simple printf("%lu",cost-3) was not enough and had to append the condition? In fact, all the other possibilities characters are handled above... |
|
|