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

Very simple algo
Posted by Mirjalol Bahodirov 16 Jul 2011 13:15
Here my algo:


#include<iostream>
using namespace std;
int main(){
    char c; int i=0;
#ifndef ONLINE_JUDGE
   freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);
#endif
while(cin.get(c)){
if(i==0&&c>='A'&&c<='Z'){cout<<c; i=1;}else{
if(c>='A'&&c<='Z')cout<<char(c-'A'+'a');
else cout<<c;
}
if(c=='.'||c=='!'||c=='?')i=0;
}
return 0; }
Re: Very simple algo
Posted by Nic Roets 1 Sep 2011 01:49
Your character count after some trimming is around 225.

My character count is 173:

#include <stdio.h>
int main ()
{
int c,i=1;
while ((c=getchar())!=EOF) {
putchar(i||c<'A'||c>'Z'?c:c-'A'+'a');
i=c>='A'&&c<='Z'?0:strchr(".?!",c)?1:i;
}
return 0;
}