空行

空行起着分隔程序段落的作用。空行得体(不过多也不过少)将使程序的布局更加 清晰。空行不会浪费内存,虽然打印含有空行的程序是会多消耗一些纸张,但是值得。 所以不要舍不得用空行。

 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     float a=3.5,b=2.1,c=0;
 7     cout<<"a="<<a<<"  b="<<b<<"  c="<<c<<endl;
 8 
 9     //与运算
10     cout<<"a&&b="<<(a&&b)<<endl;//输出1
11     cout<<"a&&c="<<(a&&c)<<endl;//输出0
12 
13     //或运算
14     cout<<"a||b="<<(a||b)<<endl;//输出1
15     cout<<"a||c="<<(a||c)<<endl;//输出1
16 
17     //非运算
18     cout<<"!a="<<!a<<endl<<"!c="<<!c<<endl;//输出0  1
19 
20     //关系运算和逻辑运算
21     bool flag=a>=0 && a<=5;  //变量a在[0,5]区间内
22     cout<<"a=>0 && a<=5="<<flag<<endl;//输出1
23 
24     //算术运算、关系运算和逻辑运算
25     cout<<"a+5>2*b+2||a<b+3="<<(a+5>2*b+2||a<b+3)<<endl;//输出1
26     return 0;
27 }
原文地址:https://www.cnblogs.com/borter/p/9406108.html