万能开头:
#include<bits/stdc++.h>
using namespace std;
在 C++ 中,using namespace std;指令允许用户使用 std 命名空间中的所有标识符,而无需在它们前面加上 std::。
标准输入输出
标准输入是 cin, cin用 >> 运算符把输入传给变量。
标准输出是 cout,用 << 运算符把需要打印的内容传递给 cout,endl 是换行符。
#include <bits/stdc++.h>
int a;
cin >> a; // 从输入读取一个整数
// 输出a
std::cout << a << std::endl;
// 可以串联输出
// 输出:Hello, World!
std::cout << "Hello" << ", " << "World!" << std::endl;
string s = "abc";
a = 10;
// 输出:abc 10
std::cout << s << " " << a << std::endl;