#include "stdio.h"
int data[100];
int n=0;
void main()
{
int c;
while(1)
{
printf("1: add number\n");
printf("2: delete number\n");
printf("3: print\n");
printf("0: exit\n");
c=scanf("%d", &c);
switch (c)
{
case 0: return;
case 1:
int i;
scanf("%d", &i);
data[n++]=i;
break;
case 2:
n--;
break;
case 3:
for(i=0;i<n;i++)
printf("%d ",data[i]);
printf("\n");
break;
}
}
}
c=scanf("%d", &c);
這麼寫,c永遠是1了。
scanf("%d", &c);