We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <stdio.h> int search(int key,int a[],int length); int main(void){ int loc; int a[]={2,4,6,7,9,11,13,23,14,32}; //printf("%d\n", sizeof(a)); //printf("%d\n", sizeof(a[0])); int x; printf("请输入一个数字:"); scanf("%d", &x); loc = search(x, a, sizeof(a)/sizeof(a[0])); if (loc != -1) { printf("%d在索引为%d的位置上\n", x, loc); }else{ printf("%d不存在\n",x); } return 0; } int search(int key,int a[],int length){ int ret = -1; int i; for(int i=0;i<length;i++){ if(a[i] == key){ ret = i; break; } } return ret; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: