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

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

最佳回答

光亮的百合

背后的网络

2026-04-06 20:08:15

#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-04-06 20:08:15

    #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

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

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