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