如何在不使用 malloc 的情况下使用这个程序?如果我使用temp.next=&newtemp
该程序没有错误?我必须学习如何避免malloc。
for(int ;;){
printf("Fusni N(numrin e qyteteve): "); scanf("%d", &N);
if(N<13 || N>100) {printf("Futet N gabim\t( 13 < N < 100)\n\n");continue;}
M=1;
while(1){
p = q = malloc(sizeof(struct node));
p->id_qyteti = 1;
for (i = 2; i <= N; ++i) {
p->pas = malloc(sizeof(struct node));
p = p->pas;
p->id_qyteti = i;
}
p->pas = q;
printf("M=%d, Zonat ku nderpritet rryma:\n", M);
for (count = N; count > 1; --count) {
printf("%d ",p->pas->id_qyteti); p->pas = p->pas->pas;
if(count==2)printf("\n\n");
for (i = 0; i < M - 1; ++i) p = p->pas;
}
if(p->id_qyteti==13)
{
printf("13.Tirana ngelet e fundit\n");
printf("M-ja minimale: %d\n", M);
break;
}
else M++;
}}
return 0;
}