0

## 變數命名的善意

``````int main()
{
int arr[10] = {99, 0, 10, 31, 0, 42, 70, 67, 0, 0};
int i, j, n1, n2;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", arr[i]);
}

printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &n1, &n2);
while(n2 != 0){
if(arr [n1 - 1] == 0){
arr[n1 - 1] = n2;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", arr[i]);
}
printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &n1, &n2);
}
else{
printf("Sorry, seat is taken.\n");
scanf("%d %d", &n1, &n2);
}
}

printf("*seating*\n");
bubble_sort(arr, 10);
for(int i = 0; i < 10; ++i){
printf("%d ", arr[i]);
}
printf("\n");
printf("***************\n");

return 0;
}
``````

``````    int arr[10] = {99, 0, 10, 31, 0, 42, 70, 67, 0, 0};
int i, j, n1, n2;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", arr[i]);
}
``````

``````    printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &n1, &n2);
``````

``````    int arr[10] = {99, 0, 10, 31, 0, 42, 70, 67, 0, 0};
int i, j, seat, number;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", arr[i]);
}

printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &seat, &number);
``````

``````int main()
{
int seats[10] = {99, 0, 10, 31, 0, 42, 70, 67, 0, 0};
int i, j, seat, number;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", seats[i]);
}

printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &seat, &number);
while(number != 0){
if(seats [seat - 1] == 0){
seats[seat - 1] = number;
printf("*seating*\n");
for(int i = 0; i < 10; ++i){
printf("%d ", seats[i]);
}
printf("\n");
printf("***************\n");
printf("Please input the seat (1~10) and 2-digit number(0 to end game)\n");
scanf("%d %d", &seat, &number);
}
else{
printf("Sorry, seat is taken.\n");
scanf("%d %d", &seat, &number);
}
}

printf("*seating*\n");
bubble_sort(seats, 10);
for(int i = 0; i < 10; ++i){
printf("%d ", seats[i]);
}
printf("\n");
printf("***************\n");

return 0;
}

``````