1 条题解

  • 0
    @ 2025-10-10 15:45:26

    C :

    #include<stdio.h>   
    
    int main(){ 
    	int a,b,c;
    	scanf("%d %d %d",&a,&b,&c);
    	
    	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 %d %d",a,b,c);
    
    	return 0;
    } 
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int a,b,c,t;
    	cin>>a>>b>>c;
    	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;
    	}
    	cout<<c<<" "<<b<<" "<<a<<endl;
    }
    

    Pascal :

    var a,b,c,t:longint;
    begin
      read(a,b,c);
      if a<b then begin t:=a;a:=b;b:=t; end;
      if b<c then begin t:=b;b:=c;c:=t; end;
      if a<b then begin t:=a;a:=b;b:=t; end;
      writeln(a,' ',b,' ',c);
    end.
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		@SuppressWarnings("resource")
    		Scanner scanner=new Scanner(System.in);
    		int x=scanner.nextInt();
    		int y=scanner.nextInt();
    		int z=scanner.nextInt();
    		int max=0;
    		if (x>y) { 
    		max=x;
    		x=y;
    		y=max;}
    		
    		if (x>z) {
    			max=z;
    		   z=x;
    		   x=max;
    		   }
    		if (y>z) {
    			max=y;
    			y=z;
    			z=max;}
    		
    		System.out.print(z+" "+y+" "+x);	
    		}
    }
    

    Python :

    a,b,c = map(int,input().split());
    # a>b>c
    if a < b:
        t=a
        a=b
        b=t 
    if a < c:
        t=a
        a=c
        c=t 
    if b < c:
        t=b
        b=c
        c=t
    print(a,b,c)
    
    • 1

    信息

    ID
    39
    时间
    1000ms
    内存
    512MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者