1
I'm golfing a program to sum two numbers in C++.
Example:
10 3
13
I found out that this problem can be solved in 54 symbols (without spaces and so on) using C++. My code (63 symbols):
#include <iostream>
main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b;
}
I have no idea how to make my program shorter. Can you help me, please?
Do the numbers have to come from STDIN? – James – 2017-06-05T19:09:43.470
DJMcMayhem, yes. – eaglemango – 2017-06-05T19:11:13.037
I don't think you can beat that if you have to use STDIN. – Magic Octopus Urn – 2017-06-05T19:18:28.693
I saw the 54-symbols result on site, where you can read data only from STDIN or file. – eaglemango – 2017-06-05T19:20:21.327
Could you link to where you saw a 54 byte solution? If you have seen a 54 byte solution why can't you use that? – Notts90 supports Monica – 2017-06-05T20:04:15.990
I haven't seen the solution code. I saw only statistics like run time, used memory and length (54 symbols without spaces and etc.) – eaglemango – 2017-06-05T20:59:02.453
3Your program can not run according to c++ standard. the function
main
should have a return type. – rahnema1 – 2017-06-06T02:25:23.223I'm voting to close this question as off-topic because it's not a programming puzzle or code golf challenge. It's not a general programming question either, though. – CalculatorFeline – 2017-06-06T02:53:34.833
@rahnema1 yes,
main
function have to be declared with a return type. Some compilers supportmain() { ... }
declaration. I used that in order to make my code shorter. – eaglemango – 2017-06-06T07:35:03.627@CalculatorFeline why do you think that's not a challenge? A goal is to write working A+B program, that will be shorter than mine. – eaglemango – 2017-06-06T07:39:26.937
9@CalculatorFeline This is a perfectly fine [tag:tips] question, no reason to close it. – TheLethalCoder – 2017-06-06T09:59:05.317