首页 > 其他 > 详细

输出多项数据

时间:2018-08-02 10:38:25      阅读:118      评论:0      收藏:0      [点我收藏+]
 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 int main(int argc, char** argv) {
 6     //输出字符常量、变量和字符串
 7     char c1=A;
 8     cout<<W;
 9     cout<<c1<<endl;
10     cout<<"This is a test."<<endl;
11     cout<<"------------------"<<endl;
12 
13     //输出整型常量、变量和表达式
14     int n=100;
15     cout<<10;
16     cout<<n;
17     cout<<2*n<<endl;   //输出整型表达式
18     cout<<"------------------"<<endl;
19 
20     //输出浮点型常量、变量和表达式
21     double pi=3.1415926,r=10.0,s=pi*r*r;
22     cout<<pi<<endl;
23     cout<<r;
24     cout<<s;
25     cout<<2*r*pi<<endl;      //输出浮点型表达式
26     cout<<"------------------"<<endl;
27     
28     //一个cout可以输出多项数据
29     cout<<W<<" "<<c1<<endl;
30     cout<<"This is a test."<<endl;
31     cout<<"pi="<<pi<<" r="<<r<<" s="<<s<<endl;
32     return 0;
33 }

 

输出多项数据

原文:https://www.cnblogs.com/borter/p/9405627.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!