作业帮 > 综合 > 作业

c++设计一个程序,输入一个三位正整数,输出其各位数字组成的最大整数,如,输入123,输出321!

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/04/28 03:26:41
c++设计一个程序,输入一个三位正整数,输出其各位数字组成的最大整数,如,输入123,输出321!
#include
using namespace std ;
int main()
{
int n;
int unit,tens,hund;
cin >> n ;
unit = n%10 ;
tens= n/10%10;
hund=n/100;
if ( hund < tens ) { int temp=hund;hund=tens;tens=temp; }
if ( hund < unit ) { int temp=hund;hund=unit;unit=temp; }
if ( tens < unit ) { int temp=tens;tens=unit;unit=temp; }
cout