有n个不同的数,从小到大排成一列。现在告诉你其中的一个数x,请你输出x在此数组中的下标

有n个不同的数,从小到大排成一列。现在告诉你其中的一个数x,请你输出x在此数组中的下标。
输入共两行

第一行为两个整数n、x

第二行为n个整数,代表a[i]
请你输出x在此数组中的下标

参考如下:

#include <stdio.h>
#include <stdlib.h>
int main() 
{
     
    int n;
    scanf("%d", &n);

    int x;
    scanf("%d", &x);

    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    int index = -1;
    for (int i = 0; i < n; i++) 
    {
        if (a[i] == x) 
        {
            index = i;
            break;
        }
    }

    if (index != -1) 
        printf("下标:%d\n", index);
    else
        printf("未找到!");

    return 0;
}

#include<stdio.h>
#include<windows.h>
void swap(int *x,int *y)
{
    *x ^= *y;
    *y ^= *x;
    *x ^= *y;
}
void integer_sort(int a[],int len)  //选择法
{
    int i = 0;
    int count = 0;
    for(;i < len-1;i++){
        int j = i+1;
        for(;j < len;j++){
            if(a[i] > a[j]){
                count++;
                swap(&a[i],&a[j]);
            }
        }
        if(!count){
            break;
        }
    }
}
int main()
{
    int i = 0;
    int a[] = {0,-1111,209,88,-435,-90,4,7};
    int sz = sizeof(a)/sizeof(a[0]);
    integer_sort(a,sz);
    for(;i < sz;i++){
        printf("%d ",a[i]);
    }
    printf("\n");
    system("pause");
    return 0;
}