c++打印代码分析
2026/4/27 13:14:07 网站建设 项目流程

格式大概std::cout<<"字符串";(大家要注意我在下面省略了

#include <iostream>,还有就是每行命令写完记得要加上;)

std::cout<<"1"<<"2";

相当于

std::cout<<"1";

std::cout<<"2";

#incude <iostream> int main(){ std::cout<<"1"; std::cout<<"2"; }

#include <iostream> int main(){ std::cout<<"1"<<"2"; }

所表示的是一样的都是12,但是如果是打印1和2怎么办呢

那么这个时候就要引用到std::endl;

这个就相当于回车

用法

#include <iostream> int main(){ #ifdef _WIN32 system("chcp 65001"); #endif std::cout<<"分"<<std::endl; std::cout<<"开"<<std::endl; }

或者是

#include <iostream> int main(){ #ifdef_WIN32 system("chcp 65001") #endif std::cout<<"分 \n 开" }

对了这是字符串的,如果是数字就不用加引号

#include <iostream> int main(){ std::cout<<11; }

或者是用print

#include <iostream> int main(){ #ifdef _WIN32 system("chcp 65001"); #endif printf("分 \n 开"); }

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询