01. 第一行输出
语法讲解 今天学: cout 可以把文字输出到屏幕,<< 是输出运算符。 #include <iostream> using namespace std; int main() { cout <<
02. 输出两行
语法讲解 今天学: endl 表示换行,每次遇到它就另起一行。 #include <iostream> using namespace std; int main() { cout << "Yes
03. 一个 cout 多行
语法讲解 今天学: 一个 cout 中可以用多个 endl 或 "\n" 实现多行输出。 #include <iostream> using namespace std; int main() {
04. 输出数字
语法讲解 今天学: cout 可以直接输出数字,不需要格式符。 #include <iostream> using namespace std; int main() { cout << 42 <&l
05. 输出带标点的句子
语法讲解 今天学: cout 会原样输出引号里的标点和空格。 #include <iostream> using namespace std; int main() { cout << "I lo
06. 拼接输出
语法讲解 今天学: 用多个 << 可以把文字和数字拼在一起输出。 #include <iostream> using namespace std; int main() { cout << 3
07. 输出制表符
语法讲解 今天学: \t 是制表符,输出时会产生一段空白间距。 #include <iostream> using namespace std; int main() { cout << "Nam
08. 用 \n 换行
语法讲解 今天学: 除了 endl,也可以在字符串里写 \n 来换行。 #include <iostream> using namespace std; int main() { cout << "
09. 读入一个整数
语法讲解 今天学: cin 可以从键盘读入数据,用 >> 运算符。 #include <iostream> using namespace std; int main() { int x; cin
10. 读入后做运算
语法讲解 今天学: 读入的数据可以参与运算。 #include <iostream> using namespace std; int main() { int x; cin >> x; c