1、
#include <stdio.h> #define max(x, y) ((x > y) ? x : y) int main(void) { int a, b, c, d; puts("please input four integers."); printf("a = "); scanf("%d", &a); printf("b = "); scanf("%d", &b); printf("c = "); scanf("%d", &c); printf("d = "); scanf("%d", &d); printf("method1 int max = %d\n", max(max(a,b), max(c,d))); printf("method2 int max = %d\n\n", max(max(max(a,b),c),d)); double m, n, i, j; puts("please input four doubles."); printf("m = "); scanf("%lf", &m); printf("n = "); scanf("%lf", &n); printf("i = "); scanf("%lf", &i); printf("j = "); scanf("%lf", &j); printf("method1 double max = %f\n", max(max(m,n),max(i,j))); printf("method2 double max = %f\n", max(max(max(m,n),i),j)); return 0; }