算法训练 最大值与最小值的计算

输入11个整数,计算它们的最大值和最小值。

样例输入

0 1 2 3 4 5 6 7 8 9 10

样例输出

10 0

#include<stdio.h>

int main(void)
{
	int shu , n = 11;
	scanf("%d", &shu );
	int zd = shu , zx = shu ;
	while( -- n > 0)
	{
		scanf("%d", &shu );
		zd = zd < shu ? shu : zd ;
		zx = zx > shu ? shu : zx ;
	}
	printf("%d %d", zd , zx );
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41353167/article/details/82155183