1 条题解

  • 0
    @ 2025-4-7 21:29:25

    C :

    int main(int argc, char* argv[])
    {
    	int a,b,c,tem;
    	while(~scanf("%d%d%d",&a,&b,&c))
    	{
    	  if(a>b)
    	  {
    	    tem=a;
    		a=b;
    		b=tem;
    	  }
    	 if(a>c)
    	  {
    	    tem=a;
    		a=c;
    		c=tem;
    	  }
    	  if(b>c)
    	  {
    	    tem=c;
    		c=b;
    		b=tem;
    	  }
    	  printf("%d %d %d \n",a,b,c);
    	}
    	return 0;
    }
    
    

    C++ :

    #include <iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    int a,b,c;
        cin>>a>>b>>c;
    if(a<b&&b<c)
        {cout <<a<< " " <<b<< " " <<c<<" " << endl;}
     else if(a<c&&c<b)
        {cout <<a<< " " <<c<< " " <<b<<" " << endl;}
     else if(b<a&&a<c)
        {cout <<b<< " " <<a<< " " <<c<<" " << endl;}
     else if(b<c&&c<a)
        {cout <<b<< " " <<c<< " " <<a<<" " << endl;}
     else if(c<a&&a<b)
        {cout <<c<< " " <<a<< " " <<b<<" " << endl;}
     else
        {cout <<c<< " " <<b<< " " <<a<<" " << endl;}
        return 0;
    }
    
    

    Pascal :

    var
     m,n,i,k,x:longint;
     a:array[-1..1000000] of longint;
    Procedure qsort(l,r:longint);
    var
     i,j,mid,p:longint;
    begin
     i:=l; j:=r;
     mid:=a[(i+j) div 2];
     repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then
       begin
        p:=a[i]; a[i]:=a[j]; a[j]:=p;
        inc(i); dec(j);
       end;
     until i>j;
     if l<j then qsort(l,j);
     if i<r then qsort(i,r);
    end;
    
    
    begin
    
     for i:=1 to 3 do
      read(a[i]);
     qsort(1,3);
     for i:=1 to 3 do
      write(a[i],' ');
    end.
    
    
    • 1

    信息

    ID
    1448
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者