#include <stdio.h>

#define SIZE 10


int main(void)
{
 char ans1;
 int ans2,i;
 int seat[SIZE] = {0};

 while(1)
 {
  printf("좌석을 예약 할건가 (y 또는 n)");
  scanf("%c",&ans1);

  if(ans1=='y' || 'Y')
  {
   printf("---------------------------\n");
   printf(" 1 2 3 4 5 6 7 8 9 10 \n");
   printf("===========================\n");

   for(i=0; i<SIZE;i++)
    printf("%d ",seat[i]);

   printf("몇번쨰 좌석을 예약할건가 ");
   scanf("%d",&ans2);
   if(ans2 <=0 ||ans2>SIZE)
   {
    printf("1부터 10사이의 숫자를 입력하시오 \n");
    continue ;
   }
   if(seat[ans2-1]==0)
   {
    seat[ans2-1]=1;
    printf("예약되었습니다 .\n");
   }
   else
    printf("이미 예약된 자리입니다.\n");
  }
  else if(ans1 =='n')
   return 0;


  }

  return 0;
 }

 

 

 

 

 

 

위 코드중에

 

 if(seat[ans2-1]==0)
   {
    seat[ans2-1]=1;
    printf("예약되었습니다 .\n");
   }

 

이부분이 잘이해가되지않는데 만약 사용자로부터 4를입력받으면

if(seat[4-1]==0)

{

seat[4-1]=1;

printf("에약되었습니다 .\n");

}

 

이렇게되는거아닌가요 뭔가이해가안되요