C++ 中常用的输出语句为 cout,语法如下:

cout << 输出内容;

其中,<< 为输出运算符,可以用于输出多个内容,例如:

cout << "Hello, world!" << endl;

cout << "The answer is " << 42 << "." << endl;

注意,cout 默认情况下会以空格分隔不同的输出内容,如果需要换行,可以使用 endl,例如:

cout << "This is the first line." << endl;

cout << "This is the second line." << endl;

另外,如果需要输出变量的值,可以直接将变量名放在输出语句中,例如:

int age = 18;

cout << "My age is " << age << "." << endl;

c++输出语句

原文地址: http://www.cveoy.top/t/topic/djXG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录