请教大佬 运行错误的原因
#include<stdio.h> #include<stdlib.h> int main() { int n; int i = 0; int j = 0; scanf("%d",&n); int flag; int* p = (int*)malloc(n*sizeof(int)); for(i = 1;i<=n;i++) { scanf("%d",p+i); } p[0] = 0; for(j = 0;j<5;j++) { p[0] = 0; for(i = 1;i<=n;i++) { if(p[i]>p[0]) { p[0] = p[i]; flag = i; } } p[flag] = 0; printf("%d ",p[0]); } free(p); p = NULL; return 0; }
#C##笔经#