1、

#include <stdio.h>
#define NUMBER 5

int main(void)
{
    int i;
    int a[NUMBER];
    
    puts("please input the score of the students.");
    for (i = 0; i < NUMBER; i++)
    {
        printf("%dst = ", i + 1);
        scanf("%d", &a[i]);
    }
    
    int max = a[0];
    int min = a[0];
    for (i = 0; i < NUMBER; i++)
    {
        if(a[i] > max)
            max = a[i];
        if(a[i] < min)
            min = a[i];
    }
    printf("max = %d\n", max);
    printf("min = %d\n", min);
    return 0;
}

c语言中求数组元素的最大值和最小值

 

 

2、

#include <stdio.h>
#define NUMBER 8

int main(void)
{
    int i;
    int a[NUMBER];
    
    puts("please input the score of the students.");
    for (i = 0; i < NUMBER; i++)
    {
        printf("%dst = ", i + 1);
        scanf("%d", &a[i]);
    }
    
    int max = a[0];
    int min = a[0];
    for (i = 0; i < NUMBER; i++)
    {
        if(a[i] > max)
            max = a[i];
        if(a[i] < min)
            min = a[i];
    }
    printf("max = %d\n", max);
    printf("min = %d\n", min);
    return 0;
}

c语言中求数组元素的最大值和最小值

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-10-14
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-12
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案