填空题

下面函数的作用是 【9】 。 int index(int x,int a[],int n) { for(int i=0;i<n;i++) { if(a[i]==x) return i; } return i; }

【参考答案】

数组a中查找x,若有则返回第一个x的下标,若没有则返回n