博客
关于我
cin与cout详解
阅读量:484 次
发布时间:2019-03-07

本文共 619 字,大约阅读时间需要 2 分钟。

//(1)std::cout详解//std::cout << "hello world"<< std::endl;//如果想直接使用cout和cin,可以加上,using namespace std;//std: 命名空间 标准库命名空间//::作用域运算符//cout:console output ,是一个对象(结构体变量),标准输出对象//<<:与cout使用时,不是左移运算符,而是运算符重载,输出运算符//<
<可以当成一个函数,有参数,左边是第一个参数,右边的"hello world"是第二个参数,就代表将第二个参数写到第一个参数里。 std::endl:也是个对象(模板函数,函数指针),也可以当成换行符,强制更新输出缓冲区,那么输出缓冲区的内容什么时候往屏幕上输出呢? a)输出缓冲区满了 b)程序执行到main的return语句 c)调用了std::endl 所谓刷新缓冲区就是把缓冲区的内容往屏幕上写 系统不繁忙时,系统也会查看缓冲区是否有内容,有的话也会往缓冲区里输出。 int x="3;//std::cout">
<< x << "的平方是" << x * x << std::endl;//x++;//std::cout << x << "的平方是" << x * x << std::endl;//多个<
<代表的意思,其中std::是有返回值的,返回一个对象std::cout 所以,std::cout << x执行成功以后返回了cout,也就是演变成了std::cout<< "的平方是" x * std::endl;这种形式,然后依次输出 要避免一下代码的出现。 int i="3;//std::cout">
<< i-- << i-- << std::endl;//(2)std::cin详解//std::cout << "请输入两个数" << std::endl;//int a, b;//std::cin >> a >> b;//std::cout << a + b << std::endl;//cin:也是一个对象,可以理解成键盘,所以std::cin>>a可以理解从从键盘输入一个数到a中//返回其左侧运算对象作为运算结果,std::cin >> a >> b;//输入输出不像printf那样要带格式控制,因为这里的输入输出是带有多个版本的,如果是整型的就用整型输出的std::cout

转载地址:http://lakcz.baihongyu.com/

你可能感兴趣的文章
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>