不用if结构,如何写程序?
例子:
int a = 12;
if(a > 10)
cout<<"a is greater than 10"<<endl;
一个思考题, 不用if,else,三目运算符?: , switch, 如何写程序好?
- do break
int a = 12;
for(; a>10; ;) {
cout<<"a is greater than 10"<<endl;
break;
}
- &&
int a = 12;
a>10 && cout<<"a is greater than 10"<<endl;