intmain() { int x{ 5 }; std::cout << "x is equal to: " << x << '\n'; // Using '\n' standalone std::cout << "And that's all, folks!\n"; // Using '\n' embedded into a double-quoted piece of text (note: no single quotes when used this way) return0; }
1 2
x 等于:5 伙计们,这就是全部!
std::cin
1 2 3 4 5 6 7 8 9
#include<iostream> intmain() { std::cout << "Enter a number: "; int x{}; std::cin >> x; std::cout << "You entered " << x << '\n'; return0; }