5、流的输入与输出
来源:互联网 发布:java的网络编程重要吗 编辑:程序博客网 时间:2024/06/04 18:28
C++定义的标准流主要包括 cin、cout、cerr、clog。
cin 是由终端输入数据,默认为键盘;
cout 为向终端输出数据,默认为屏幕;cerr 是向终端输出标准错误信息,默认为屏幕;
clog 为 cerr 的缓冲形式,默认为屏幕。
用博客链接 中的例子,使用 cin() 和 cout() 计算两个日期之间的天数之差。
#include<iostream>#include<math.h>using namespace std;int f(int year,int month){if (month<3){return year-1;}else{ return year;}}int g(int month){if (month<3){return month+3;}else{ return month+1;}}int N_Value(int year,int month,int day){int N = 1461*f(year,month)/4+153*g(month)/5+day;return N;}void main(){ int year1,mongth1,day1,year2,mongth2,day2,N1,N2,dN; cout<<"Please input integer year,mongth,day,the first date:"<<endl; cin>>year1>>mongth1>>day1; cout<<"Please input integer year,mongth,day,the seconddate:"<<endl; cin>>year2>>mongth2>>day2; N1 = N_Value(year1,mongth1,day1); N2 = N_Value(year2,mongth2,day2); dN = abs(N1-N2); printf("There are %d days between the two dates.\n",dN);}
0 0
- 5、流的输入与输出
- “【】”的输入与输出
- 输入与输出,流!
- 输入流与输出流的总结
- 输入流与输出流的区别
- 输入流与输出流的区别
- JAVA---IO流的输入与输出
- C++的输入和输出与标准输出流
- C++的输入和输出与标准输出流
- C++的输入和输出与标准输出流
- shell的输入与输出
- Linux_shell_shell的输入与输出
- 数据的输入与输出
- java 的输入与输出
- 文件的输入与输出
- io的输入与输出
- 数据的输入与输出
- avCaptureDevice 的输入与输出
- 3899
- Shader之学习笔记六
- 1007. Maximum Subsequence Sum
- mysql连接url中useUnicode=true&characterEncoding=UTF-8的作用
- 多通道的同步问题
- 5、流的输入与输出
- leetcode 232. Implement Queue using Stacks
- 表示数值的字符串
- vlc2.2.4在64位ubuntu下的交叉编译
- 3915
- Linux系统mysql远程连接设置
- 1008. Elevator
- Ubuntu14.04+CUDA8.0+GTX1080+caffe
- Linux入门:进度条小程序