1 solutions

  • 0
    @ 2025-3-3 16:33:59

    C :

    #include<stdio.h>   
    
    int main(){ 
    	int x;
    	scanf("%d",&x);
    	
    	int a = x / 100;
    	int b = x / 10 % 10;
    	int c = x % 10;
    	
    	
    	if(a < b){
    		int t = a;
    		a = b;
    		b = t;
    	}
    	
    	if(b < c){
    		int t = b;
    		b = c;
    		c = t;
    	}
    	
    	if(a < b){
    		int t = a;
    		a = b;
    		b = t;
    	}
    	
    	printf("%d",a * 100 + b * 10 + c);
    
    	return 0;
    } 
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int a,b,c,n,t,x;
    	cin>>n;
    	a=n/100;
    	b=n/10%10;
    	c=n%10;
    	//cout<<a<<" "<<b<<" "<<c<<endl;
    	
    	if(a>b){
    		t=a;
    		a=b;
    		b=t;
    		
    	}
    	if(b>c){
    		t=b;
    		b=c;
    		c=t;
    	}
    	if(a>b){
    		t=a;
    		a=b;
    		b=t;
    	}
    	x=c*100+b*10+a*1;
    	cout<<x<<endl;
    }
    

    Python :

    a = int(input());
    b = a // 100;
    s = a // 10 % 10;
    g = a % 10;
    if b < s :
        t = b;
        b = s;
        s = t;
    
    if b < g :
        t = b;
        b = g;
        g = t;
    
    if s < g :
        t = s;
        s = g;
        g = t;
    
    print(b * 100 + s * 10 + g);
    
    
    
    • 1

    【入门】求任意三位数打乱次序后的最大值

    Information

    ID
    10847
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By