输入输出¶
cin, cout¶
C++语言的输入输出
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a + b;
return 0;
}
This operator (>>) applied to an input stream is known as extraction operator. (Extracts and parses characters sequentially from the stream)
This operator (<<) applied to an output stream is known as insertion operator. (inserts them into the output stream)
scanf, printf¶
C语言的输入输出
格式化输入输出语句
#include <cstdio>
using namespace std;
int main() {
int a, b;
scanf("%d%d", &a, &b);
printf("%d", a + b);
return 0;
}
如果要一次输出多个变量
在双引号里面,就是要输出的格式,占位符与后面的变量一一对应