c语言 用指针 来判断N个数里最大直 最小直
来源:百度知道 编辑:UC知道 时间:2024/05/25 07:46:59
LINUX下运行结果:
How many integers will be specified? 1
Integer #1: 2
--------------------------------------
MAX = 2 MIN = 2
GY@localhost\ ./a.out
How many integers will be specified? 5
Integer #1: 1
Integer #2: 2
Integer #3: 3
Integer #4: 4
Integer #5: 5
--------------------------------------
MAX = 5 MIN = 1
#include <stdio.h>
int main(void)
{
int index = 0, max, min, i, *ptr;
while(! index) {
printf("How many integers will be specified? ");
scanf("%i", &index);
index = (index > 0) ? index : 0;
}
int values[index];
for (i = 0; i < index; i++) {
printf("Integer #%i: ", i + 1);
scanf("%i", &values[i]);
}
int *arrayEnd = values