1 solutions
-
0
C :
#include<stdio.h> int main(){ int i,j; double a[3],temp; scanf("%lf %lf %lf",&a[0],&a[1],&a[2]); for (i=0;i<2;i++) for (j=i+1;j<3;j++) if (a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } for (i=0;i<2;i++) printf("%.2lf ",a[i]); printf("%.2lf",a[i]); printf("\n"); return 0; }C++ :
#include <stdio.h> int main() { float a, b, c, t; scanf("%f %f %f", &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; } printf("%.2f %.2f %.2f\n", a, b, c); return 0; }Pascal :
var a:array[1..3] of real; i,j:longint; t:real; begin for i:=1 to 3 do read(a[i]); readln; for i:=1 to 2 do for j:=i+1 to 3 do if a[i]>a[j] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end; for i:=1 to 2 do write(a[i]:0:2,' '); writeln(a[3]:0:2); end.Java :
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); ArrayList<Double> arr=new ArrayList<Double>(); arr.add(cin.nextDouble()); arr.add(cin.nextDouble()); arr.add(cin.nextDouble()); Collections.sort(arr); System.out.printf("%.2f %.2f %.2f\n", arr.get(0),arr.get(1),arr.get(2)); } }Python :
print ' '.join("%.2f" %x for x in sorted(float(x) for x in raw_input().split()))
- 1
Information
- ID
- 16643
- Time
- 1000ms
- Memory
- 32MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By