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

学习 时间:2026-10-08 15:33:55 阅读:2320
c++设计一个程序,输入一个三位正整数,输出其各位数字组成的最大整数,如,输入123,输出321!

最佳回答

醉熏的乌冬面

坚定的舞蹈

2026-10-08 15:33:55

#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

最新回答共有2条回答

  • 认真的手套
    回复
    2026-10-08 15:33:55

    #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

上一篇 假如地球的质量变大,可能会产生什么影响

下一篇 来苏水适合家用消毒吗