pages:
  • 1
Ln (x) dx SAYS

OOOOhhhhhhhhh! How can i reduce my code length in c++?

MaHaN Tp SAYS

Show your code

Ln (x) dx SAYS

It's 82 characters length. I want to get 74.

#include<iostream>
int main()
{
    for(int a,b;std::cin>>a>>b;std::cout<<a+b<<std::endl);  
}
MaHaN Tp SAYS

I think it can't be less than this :

#include<iostream>
int main(){int a,b;while(std::cin>>a>>b)std::cout<<a+b<<std::endl;}
Ln (x) dx SAYS

no it's 1 character longer. it's 83 chars.

AMiR SAYS

K Λ K T ♥ ♥ Ӡ said:

It's 82 characters length. I want to get 74.

#include<iostream>
int main()
{
    for(int a,b;std::cin>>a>>b;std::cout<<a+b<<std::endl);  
}

You don't have to specifiy your main function returns int. Just drop the int in int main(). This reduces the length to 79.

You can also replace std::endl with "\n". This will get you to 74 characters.

Moh$en SAYS
while 1:
    print sum(map(int,raw_input().split()))