1 条题解
-
0
C :
#include<stdio.h> void fun(int *p, int *q,int *r) { int x,y,z; x=*p<*q?*p:*q; x=x<*r?x:*r; z=*p>*q?*p:*q; z=z>*r?z:*r; y=*p+*q+*r-x-z; printf("%d %d %d\n",x,y,z); } int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); fun(&a,&b,&c); return 0; }
C++ :
#include <stdio.h> int main() { int *pa, *pb, *pc, *t; int a, b, c; scanf("%d %d %d", &a, &b, &c); pa = &a; pb = &b; pc = &c; if (*pa > *pb) { t = pa; pa = pb; pb = t; } if (*pa > *pc) { t = pa; pa = pc; pc = t; } if (*pb > *pc) { t = pb; pb = pc; pc = t; } printf("%d %d %d\n", *pa, *pb, *pc); return 0; }
Pascal :
var n,i,j,t,s:longint;a:array[1..10000] of longint; begin n:=3; for i:=1 to n do read(a[i]); for i:=1 to n-1 do for j:=1 to n-1 do if a[j]>a[j+1] then begin t:=a[j];a[j]:=a[j+1];a[j+1]:=t;end; for i:=1 to n-1 do write(a[i],' ');writeln(a[n]); end.
Java :
import java.util.Arrays; import java.util.Scanner; public class Main{ private static Scanner s = new Scanner(System.in) ; public static void main(String[] args) { int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int x[] = new int[3] ; x[0] = a ; x[1] = b ; x[2] = c ; Arrays.sort(x); System.out.println(x[0]+" "+x[1]+" "+x[2]); } }
Python :
a,b,c=sorted([int(i) for i in raw_input().split()]) print "%d %d %d"%(a,b,c)
- 1
信息
- ID
- 1357
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者