众众众所统治A+B Problem很简单 就是:
#include<iostream>
using namespace std;
int main(){
int a,b;cin >> a >> b;
cout << a+b <<endl;
return 0;
}应该是个入学过OI就会吧 但这样未免太简单了
咱们就可以将int改为long long
就是:
#include<iostream>
using namespace std;
int main(){
long long a,b;cin >> a >> b;
cout << a+b <<endl;
return 0;
}但是这样太不整洁了
都学过函数吧,可以用函数来整洁一下
就是:
#include<iostream>
using namespace std;
void init(long long a,long long b){
cin >> a >> b;
cout << a+b <<endl;
}
int main(){
long long a,b;
init(a,b);
return 0;
}你们没发现每次写一个long long太麻烦了 就可以用一个宏定义
belike:
#include<iostream>
typedef long long ll;
using namespace std;
void init(ll a,ll b){
cin >> a >> b;
cout << a+b <<endl;
}
int main(){
ll a,b;
init(a,b);
return 0;
}咱们先加个ios快读 也就是:
#include<iostream>
typedef long long ll;
using namespace std;
void init(ll a,ll b){
cin >> a >> b;
cout << a+b <<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll a,b;
init(a,b);
return 0;
}也可以用匿名函数(不过用支持auto的
#include<iostream>
typedef long long ll;
using namespace std;
int main(){
ll a,b;
cin >> a >> b;
auto add = [](ll a,ll b){return a+b;};
cout << add(a,b);
return 0;
}