代码: #include<stdio.h> #include<string.h> #include<stdlib.h> void main() { int a[50]={0}; int j=0,i=0,n=0,m=0; printf("please input the mark(student number between 0-50)and end with a number litter than 0: \n"); for(j=0;j<50;j++) { scanf("%d",&a[j]); if(a[j]<0) { break; } } int *q = (int *)malloc(j-2); q=&a[0]; while(m==0) { printf("please input the student you want to search\n"); scanf("%d",&i); printf("%d\n",*(q+i-1)); printf("if you want to continue plesae input 0,enter any to esc:\n"); scanf("%d",&m); } if(q!=NULL) { free(q); q=NULL; } }