📜  搜索数组元素 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:40.954000             🧑  作者: Mango

代码示例1
#include 

int main()
{
    int ara[10]={1,2,3,4,5,6,7,8,9,10};
    int i,is_found=-1,search_value;
    printf("Enter search value:\n");
    scanf("%d",&search_value);
    for(i=0;i<10;i++){
        if(ara[i]==search_value){
            is_found=i;
        }
    }
    
    if(is_found==-1){
        printf("Item not found\n");
        
    }else{
        printf("Item found at index on. %d\n",is_found);
    }

    return 0;
}