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

问题描述:

c++设计一个程序,输入一个三位正整数,输出其各位数字组成的最大整数,如,输入123,输出321!
1个回答 分类:综合 2014-11-05

问题解答:

我来补答
#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
 
 
展开全文阅读
剩余:2000
下一页:练习2.3