调用自定义函数search(int list[], int n),在数组中查找某个数
生活随笔
收集整理的這篇文章主要介紹了
调用自定义函数search(int list[], int n),在数组中查找某个数
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Description
輸入10個整數(shù)存儲到數(shù)組a,再輸入一個整數(shù)x,在數(shù)組a中查找x,若找到則輸出相應(yīng)的下標(biāo),否則顯示"Not found"。要求定義和調(diào)用函數(shù)search(int list[], int n, int x),在數(shù)組list中查找元素x,若找到則返回相應(yīng)下標(biāo),否則返回-1.
Input
多組測試數(shù)據(jù),每組先輸入10個整數(shù),再輸入一個x
Output
輸出x在數(shù)組中的下標(biāo)或"Not found"
Sample Input
1 2 3 4 5 6 7 8 9 10 5
1 2 3 4 5 6 7 8 9 10 20
Sample Output
4
Not found
總結(jié)
以上是生活随笔為你收集整理的调用自定义函数search(int list[], int n),在数组中查找某个数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: yii2 mysql查询_Yii2 数据
- 下一篇: 首字母变大写