0
当我Enter
新的价值,他们应该在View
显示像如何打印值列表?
1. 1 2 3 4 5 //first values
2. 6 5 9 8 3 // second values
3. 4 2 3 8 5 // ...
列表,而是它打印只是第一个值的整个列表。如果可能的话,我尝试修复这个没有二维数组的问题。有任何想法吗?
#include <stdio.h>
#define LENGTH 5
const char *menuMsg = "\n\n\t Menu \n\n\t v (View)\n\t e (Enter)\n\t q (Quit)\n";
int main(){
int run = 1;
while(run){
puts(menuMsg);
char choice;
scanf(" %c", &choice);
int x, z;
int a[LENGTH];
int list=6;
if(choice=='e') {
for(x=0; x<LENGTH; x++){
printf("Enter nr.%d: ", x+1);
scanf("%d", &a[x]);
}
z++;
}
else if(choice=='v') {
for(z=0; z<list; z++){
printf("\n%d. ", z+1);
for(x=0; x<LENGTH; x++){
printf("%d ", a[x]);
}
}
}
else if(choice=='q') run = 0;
}
return 0;
}
'一个[长度]'只保存数据的一行。你应该继续使用一个2维数组。 –