关于题面码风的问题

P1001 A+B Problem

dxrS @ 2022-12-28 10:15:51

RT,在 C++ 代码中,除了 a+b 都加了空格,看着怪怪的,请求修正码风!(强迫症真的看不下去)

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

by LittleAcbg @ 2022-12-28 11:58:22

@lv_mao_da_lao 吓死蒟蒻了


by yj768988 @ 2023-01-05 11:05:00

几大码风

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}
#include<iostream>

using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}
#include<iostream>

using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

by yj768988 @ 2023-01-05 11:09:41

不完全哈


by Zaoly @ 2023-01-07 00:40:47

Visual Studio 里甚至要求 a + b 中间也有空格。


by Zaoly @ 2023-01-07 00:43:15

不过那行

#include <cstdio>

是真的多余。


by Sweet_Home @ 2023-01-28 09:12:41

@qwqawaqaq 同感,空格真的难受,没办法啊,也不可能为了某某某统一马蜂


by 10chen01 @ 2023-02-03 11:24:56

不难受呀,能更让人一目了然的看清运算优先级

而且统一不会误导萌新os<<和is>>都不用看运算符优先级的吗。。。

说优化也是应该是加括号更一目了然:

#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b) <<endl;
    return 0;
}

by Zky20110607 @ 2023-02-19 19:38:27

#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >>a>>b;
    cout <<a+b<< endl;
    return 0;
}

上一页 |