c语言求三个数中的最大值和最小值 的算法
c语言求三个数中的最大值和最小值 的算法
程序代码:
#include<stdio.h> int main(void) { int x1, x2, x3, max, min; scanf("%d%d%d", &x1, &x2, &x3); if(x1 > x2 && x1 > x3) if(x2 > x3) min = x3; else min = x2; max = x1; if(x2 > x1 && x2 > x3) if(x1 > x3) min = x3; else min = x1; max = x2; if(x3 > x2 && x3 > x1) if(x2 > x1) min = x1; else min = x2; max = x3; printf("max = %d\nmin = %d\n", max, min); }