请问C++能写的更短吗

P1001 A+B Problem

zxyluogu @ 2021-07-18 16:01:41

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

除了 # 开头的那行外压成1行,如果换行算2字符一共应该是70字符
两个 std:: 比一个 using namespace std; 短

另:问一下用哪种语言最短


by __凉皮__ @ 2021-07-18 16:03:48

不同题目视情况而定吧

比如A+B高精PY肯定比C++短!


by LRY314 @ 2021-07-18 16:06:25

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

by ud2_ @ 2021-07-18 16:08:10

@LRY314 这已经不是 C++ 了。


by Nemonade @ 2021-07-18 16:37:21

@zxyluogu main前面的int可以省略,不知道你咕行不行


by SunsetSamsara @ 2021-07-18 16:55:43

@zxyluogu

extern "C"{int scanf(const char * ,...);int printf(const char * ,...);}int main(){int a,b;scanf("%d%d",&a,&b);printf("%d\n",a+b);}

by SunsetSamsara @ 2021-07-18 16:56:29

@zxyluogu 一共一行


by SunsetSamsara @ 2021-07-18 16:58:01

extern "C"{int scanf(char*,...);int printf(char*,...);}main(){int a,b;scanf("%d%d",&a,&b);printf("%d",a+b);}

这样也行


by zxyluogu @ 2021-07-18 19:28:45

@Canstant0x5F3759DF 你这个是行数最少的,但不是字符数最少的


by zxyluogu @ 2021-07-18 19:31:28

@nemonadeMC 可以,66字符(按windows换行算2字符计)


by Genshineer @ 2021-07-28 17:50:36

@zxyluogu

s = input().split()
print(int(s[0]) + int(s[1]))

| 下一页