题解 | #求最大最小数-用补码写int32minmax#
求最大最小数
https://www.nowcoder.com/practice/82e5ff335eeb486aab359767895cc7b4
#include<stdio.h>
int main(void)
{
int len;
scanf("%d",&len);
int min = 0x7fffffff;
int max = 0x80000000;
int tmp =0;
while(len--)
{
scanf("%d",&tmp);
min=min>tmp?tmp:min;
max=max>tmp?max:tmp;
}
printf("%d %d",max,min);
}
int main(void)
{
int len;
scanf("%d",&len);
int min = 0x7fffffff;
int max = 0x80000000;
int tmp =0;
while(len--)
{
scanf("%d",&tmp);
min=min>tmp?tmp:min;
max=max>tmp?max:tmp;
}
printf("%d %d",max,min);
}