intmain() { int a,b; printf("请输入两个整数:"); scanf("%d %d", &a, &b); int max = 0; if ( a > b ) { max = a; } else { max = b; } printf("大的那个是%d\n", max); return0; }
内容多,但易懂
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<stdio.h>
intmain() { int a,b; printf("请输入两个整数:"); scanf("%d %d", &a, &b); int max = b; if ( a > b ) { max = a; } printf("大的那个是%d\n", max); return0; }
intmain() { int hour1, minute1; int hour2, minute2; scanf("%d %d", &hour1, &minute1); scanf("%d %d", &hour2, &minute2); int ih = hour2-hour1; int im = minute2-minute1; if ( im<0 ) { im = 60+im; ih --; } printf("时间差是%d小时%d分。、n", ih, im); return0; }
intmain() { int x; scanf("%d", &x); int f=0; if ( x < 0 ) { f = -1; } else { if ( x == 0 ) { f = 0; } else { f = 2 * x; } } printf("%d\n", f); return0; }
intmain() { int a,b,c; scanf("%d %d %d", &a, &b, &c); int max = 0; if ( a > b ) { if ( a > c) { max = a; } else { max = c; } } else { if ( b > c ) { max = b; } else { max = c; } } printf("The max is %d\n", max); return0; }
intmain() { int a,b,c; scanf("%d %d %d", &a, &b, &c); int max = 0; if ( a > b ) if ( a > c) max = a; else max = c; else if ( b > c ) max = b; else max = c; printf("The max is %d\n", max); return0; }