if语句
if(表达式{语句;}
例1:
int a,b;
cin>>a>>b;
if(a>b) cout<<a;
else cout<<b;
retrun 0;
例2:
#include<iostream>
using namespace std;int main()
{
int cup;
float a,b;
cout<<"cup=";
cin>>cup;
a=cup*3*0.88;
b=(cup-cup/8)*3;
if(a>b) cout<<"大洋商城"<<endl;
else cout<<"百汇商厦"<<endl;
return 0;
}
例3:
#include<iostream>
using namespace std;
int main()
{
int cup;
float a,b;
cout<<"cup=";
cin>>cup;
a=cup*3*0.88;
b=(cup-cup/8)*3;
cout<<a-b<<endl;
return 0;
}