[c++]C++学习笔记001.cout/cin
来源:互联网 发布:java crm 源码 编辑:程序博客网 时间:2024/05/21 11:19
#include <iostream>int main (){using namespace std;int carrots; //声明变量carrots = 25;//赋值cout << "I have "; cout << carrots; cout << " carrots.";cout << endl;carrots = carrots - 1;cout << "Crunch, crunch. Now I have " << carrots << " carrots." << endl; //cout的拼接return 0;}//使用cout打印字符串、变量//插入运算符(<<)为其后的数据类型相应地调整行为
#include <iostream>int main(){using namespace std;int carrots;cout << "How many carrots do you have?" << endl;cin >> carrots;cout << "There are two more!" << endl;carrots += 2;cout << "Now you have " << carrots << " carrots." << endl;return 0;}//使用cin获取键盘输入的值
#include <iostream>void simon(int n){using namespace std;cout << "Simon says touch your toes " << n << " times." << endl;}void add(int a,int b){using namespace std;cout << a << '+' << b << '=' << a+b << endl;}int main (){// using namespace std; //使用所有名称using std::cin; //使用cinusing std::cout;//使用coutusing std::endl;//使用endlsimon(3);cout << "Pick an integer: ";int count;cin >> count;simon(count);cout << "Done!" << endl; //endl在iostream中定义,位于名称空间std;int a,b;cin >> a >> b;add(a,b);return 0;}
类是C++中面向对象编程(OOP)的核心概念之一
类是一种数据类型
类型 -> 变量
类 -> 对象
类定义描述的是数据格式及其用法,对象是根据数据格式规范创建的实体。
cin是istream类对象,在istream中定义
cout是istream类对象,在ostream中定义
0 0
- [c++]C++学习笔记001.cout/cin
- 【C/C++】Cin与Cout
- <C++>_浅谈cin&cout
- 学习笔记(二)cout和cin
- C++Primer学习笔记(一):cin与cin.get()
- C++/GUI/Qt学习——如何在Console中使用cin、cout、cerr
- C语言中cin和cout高级格式化操作
- cin cout里面的c是哪个单词的首字母?
- C++对C的扩展之cin与cout
- c/c++ cin>> cout<< scanf() printf() 返回值
- 讨论C++的cin/cout与C的scanf/printf
- C语言笔记--cin.fail()
- C/C++学习笔记2 - cin深入分析(上) - cin输入操作处理(原创)
- C/C++学习笔记3 - cin深入分析(下) - cin的错误处理(原创)
- C/C++学习笔记2 - cin深入分析(上) - cin输入操作处理
- eclipse C/C+ CDT中scanf、cin、 printf、cout不能debug输入输出的问题
- cin/cout
- cin & cout
- BZOJ1475方格取数
- cocos2dx_3.X项目重新写(一)帧动画的改变
- 多线程与runloop
- 单例模式
- img的src更改失败原因:JS文件放在了头部引入
- [c++]C++学习笔记001.cout/cin
- android 左上角返回上一级的实现
- Java NIO Channel
- python tuple整理
- OC字符串排序
- Partitioning by Palindromes uva111584
- 奇异值分解(SVD)的之低秩近似和特征降维
- JAVA5多线程---Condition使用---线程通信 --wait及notify方法
- PopupWindow