ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1601. AntiCAPS

Whats wrong with that C++ program ?!? WA#2
Posted by Plamen_Iliev 17 Jun 2008 19:51
#include<iostream>
#include<string>
using namespace std;
int main ()
{
    char c;
    int i,sz,l=0,l1=0;
    while(cin.get(c))
{
    if(l1==0&&c>='A'&&c<='Z'){cout<<c;l1=1;continue;}
    if(c==' '||c==','||c=='-'||c=='\n')cout<<c;
    else
    if(c=='.'||c=='?'||c=='!'){cout<<c;l=1;}
    else
    if(l==1){cout<<c;l=0;}
    else
    cout<<char(c-('A'-'a'));
}
    return 0;
}





Whats wrong ??????
Re: Whats wrong with that C++ program ?!? WA#2
Posted by Madhav 18 Jun 2008 00:08
u r program's output for these test cases is wrong
1)
--hello
World

2)
"--hELLO"
WORLD
Re: Whats wrong with that C++ program ?!? WA#2
Posted by Alexander Sokolov [MAI-7] 20 Aug 2008 04:04
These test cases are wrong.
Your variable l1 is allways 1 except for the beginning of the input file, you should set it to 0 after the end of the sentence.