1 条题解

  • 0
    @ 2021-6-15 10:13:24

    C :

    #include<stdio.h>
    int main()
    {
    	double s[50];
    	double t;
    	int i;
    
    	for (int j = 0; j < 3; j++)
    	{
    		scanf("%lf", &s[j]);
    	}
    	for (i = 0; i < 3; i++)
    	{
    		if (s[i-1] > s[i])
    		{
    			t = s[i-1];
    			s[i-1] = s[i];
    			s[i] = t;
    		}
    	}
    	for (int j = 0; j < 3; j++)
    	{
    		printf("%.3lf ", s[j]);
    	}
    	printf("\n");
    }
    
    

    C++ :

    #include <cstdio>
    #include <cstdlib>
    int swap(float &a,float &b){
      float t;
      if (a>b) { t=a;a=b;b=t;}
    }
    int main(){
    float a, b, c, t;
      scanf("%f%f%f", &a, &b, &c);
      if(a > b) swap(a,b);
      if(a > c) swap(a,c);
      if(b > c) swap(b,c);
      printf("%.3f %.3f %.3f\n", a, b, c);
      //system("pause");
      return 0;
    }
    

    Pascal :

    var max,a,b,c:real;
    begin
    readln(a,b,c);
    max:=0;
    if c<b then begin max:=b;b:=c;c:=max;end;
    if b<a then begin max:=a;a:=b;b:=max;end;
    if c<b then begin max:=b;b:=c;c:=max;end;
    writeln(a:0:3,' ',b:0:3,' ',c:0:3);
    end.
    
    • 1

    信息

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