|
|
вернуться в форумWA#19 can you help me? Послано Sorn 30 дек 2014 18:39 #include<iostream> #include<string> using namespace std; int main () { string s; cin>>s; int max=0,i=0,index=0,a=0,p=0; for (i=0; i<s.size()-5; i++) { if(s[i]>'a' && s[i]<='z') p--; if(s[i]=='S') p+=2; if(s[i+1]=='a') p+=2; if(s[i+1]>='A' && s[i+1]<='Z') p--; if(s[i+2]=='n') p+=2; if(s[i+2]>='A' && s[i+2]<='Z') p--; if(s[i+3]=='d') p+=2; if(s[i+3]>='A' && s[i+3]<='Z') p--; if(s[i+4]=='r') p+=2; if(s[i+4]>='A' && s[i+4]<='Z') p--; if(s[i+5]=='o') p+=2; if(s[i+5]>='A' && s[i+5]<='Z') p--; if (p>max) { max=p; index=i; } p=0; } i=index; if (s[i]!='S' && s[i]>='A' && s[i]<='Z' || s[i]=='s') a+=5; else if (s[i]!='S' && s[i]>='a' && s[i]<='z') a+=10; if (s[i+1]!='a' && s[i+1]>='a' && s[i+1]<='z' || s[i+1]=='A') a+=5; else if (s[i+1]!='a' && s[i+1]>='A' && s[i+1]<='Z') a+=10; if (s[i+2]!='n' && s[i+2]>='a' && s[i+2]<='z' || s[i+2]=='N') a+=5; else if (s[i+2]!='n' && s[i+2]>='A' && s[i+2]<='Z') a+=10; if (s[i+3]!='d' && s[i+3]>='a' && s[i+3]<='z' || s[i+3]=='D') a+=5; else if (s[i+3]!='d' && s[i+3]>='A' && s[i+3]<='Z') a+=10; if (s[i+4]!='r' && s[i+4]>='a' && s[i+4]<='z' || s[i+4]=='R') a+=5; else if (s[i+4]!='r' && s[i+4]>='A' && s[i+4]<='Z') a+=10; if (s[i+5]!='o' && s[i+5]>='a' && s[i+5]<='z' || s[i+5]=='O') a+=5; else if (s[i+5]!='o' && s[i+5]>='A' && s[i+5]<='Z') a+=10; cout<<a<<endl; return 0; } Edited by author 30.12.2014 18:40 Edited by author 03.01.2015 17:13 Edited by author 03.01.2015 17:13 Re: WA#19 can you help me? Послано Dmitri 15 июл 2017 02:42 Try Dandro (must be 5, feeling like ur programm returns 10) |
|
|