Explain This Please:

0 Mohamed Hosean · October 5, 2014
#include <cstdio>

char a[105];main(){int i=1,f=1;gets(a);for(;a; )f&=(a[i++]<'a');for(i=0;a ; )putchar(a[i++]^f*32);}

Post a Reply

Replies

Oldest  Newest  Rating
0 Horacio Accipiter · October 5, 2014
It's code that invokes undefined behavior.
The for loops have no terminating conditions, making them read beyond array bounds.

Also, it's not even standard C++. main's return type should be int.
Not to mention gets() is removed in C++14.
0 Mohamed Hosean · October 6, 2014
but it is an answer to Caps Lock problem in codeforces:-
--------------
http://codeforces.com/problemset/problem/131/A
--------------
0 Horacio Accipiter · October 6, 2014
It's a wrong answer.
0 Mohamed Hosean · October 6, 2014
no, it is accepted and all the answers in c++ are the same as this /images/forum/upload/2014-10-06/65a685f6c8cac951eed7e7e72d482b7b.PNG
0 Horacio Accipiter · October 7, 2014
Okay, I'll pastebin my reply because buckysroom likes to mess up code.

http://pastebin.com/sfd1g4J5
0 Mohamed Hosean · October 8, 2014
and you are awesome 
thank you 
  • 1

C++

107,007 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator