4.C++条件表达式的简单使用

#include <iostream> 
using namespace std;
int main(){
	int a,b,x;
	cout<<"input the value of a:\n";
	cin>>a;
	cout<<"input the value of b:\n";
	cin>>b;
	x=a-b>0?a-b:b-a;
    cout<<"The difference of a and b is:\t\t"<<x;
	return 0;
	
}

 

©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页