关于#算法#的问题:则输出99.请设计并实现一算法,传入数字n即可输出第n个大的数(语言-c语言)

有10个互不相同的整数: 99,200, 95、 87, 98、-12, 30, -87, 75,-25,不用排序,每当输入一个1-10之间的数n,即可输出第n个大的数

定义一个大小为n的数组,先将前n个数放到这个数组,求这个数组中的最小数,然后将最小数和后面的数比,如果后面的数比最小数大,那么将这个数替换数组中的最小数后,继续获取数组的最小数,循环上述步骤直至比完全部整数


#include<stdio.h>
#include<string.h>
int main() {
    int num[10] = { 99,200, 95, 87, 98, -12, 30, -87, 75,-25 };
    int n = 0;
    int nmax = 200;
    int temp = 0;
    scanf("%d",&n);
    while (n>1)
    {
        temp = -87;
        for (int i = 0; i < 10; i++)
        {
            if (temp<num[i] && num[i]<nmax)
            {
                temp = num[i];
            }
        }
        nmax = temp;
        n--;
    }
    printf("%d",nmax);
    return 0;
}