码迷,mamicode.com
首页 > 其他好文 > 详细

输出多项数据

时间:2018-08-02 11:29:47      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:ram   har   loop   color   int   code   use   ogr   常量   

 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 }

 

输出多项数据

标签:ram   har   loop   color   int   code   use   ogr   常量   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!