c how to program 习题2.23

发布于2020-03-12 823 热度

//c how to program 习题2.23
#include <stdio.h>

int main(void)
{
	int a, b, c, d, e;
	printf("请输入5个不同的整数:");
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	
	int smallest, largest;
	if(a > b){
		largest = a;
		smallest = b;
	}
	if(a < b){
		largest = b;
		smallest = a;
	}
	if(c > largest){
		largest = c;
	}
	if(c < smallest){
		smallest = c;
	}
	if(d > largest){
		largest = d;
	}
	if(d < smallest){
		smallest = d;
	}
	if(e > largest){
		largest = e;
	}
	if(e < smallest){
		smallest = e;
	}
	printf("Smallest is %d\n", smallest);
	printf("largest is %d\n", largest);
}

记录工作,记录学习,分享知识,分享经验……