게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c+이나 컴공이신분??
게시물ID : freeboard_419867짧은주소 복사하기
작성자 : 공기밥쏜다
추천 : 0
조회수 : 715회
댓글수 : 18개
등록시간 : 2010/05/08 21:03:30
안녕하세요. 오유 눈팅족인데.. 이 소스를 exe파일로 만들고 싶은데 
할줄을 모르겠네요.ㅠㅠ 프로젝트 만들고 파일만들어서 금방한다는데 정말 몰겠음..  c+의 c도 모르거든요
exe파일 하실줄 아시면.. 만드시고 댓글올려주면 감사요.ㅠㅠ


#include <stdio.h>
#include <stdlib.h>

typedef struct _tSEAT{
   int iseatnumber;
   struct _tSEAT *next;
   struct _tSEAT *prev;
}tSEAT;

 

int PrintMenu();
void InitSeat();
void AddSeat();
void DeleteSeat();
void AllDeleteSeat();
void PrintSeat(int nAllowed);

 

tSEAT *head, *tail;

 

int main()
{
   int nAllowed; // 메모리 할당량
   int iQuit;
 
   iQuit = 1;
   nAllowed = 1;

   InitSeat();

  

   while( iQuit ) {

      switch( PrintMenu() )
      {
           case 1:
              AddSeat();
              printf("추가 되었습니다.\n");
              break;


           case 2:
              DeleteSeat();
              printf("삭제 되었습니다.\n");
              break;
           case 3:
              PrintSeat(nAllowed);
              break;
           case 4:
              AllDeleteSeat();
              iQuit = 0;
              break;
           default:
              break;
      }
  
  }

 free(head);
 free(tail);


 return 0;

 

}


void InitSeat()
{
 head = (tSEAT *)malloc(sizeof(tSEAT));
 tail = (tSEAT *)malloc(sizeof(tSEAT));

 head->next = tail;
 head->prev = head;
 head->iseatnumber = 0;

 tail->next = tail;
 tail->prev = head;
 tail->iseatnumber = 0;
}

 

void AddSeat()
{
 tSEAT *NewSeat;

 NewSeat = (tSEAT *) malloc ( sizeof(tSEAT) ); 
  
 tail->prev->next = NewSeat;
 NewSeat->prev = tail->prev;
 tail->prev = NewSeat;
 NewSeat->next = tail;


 NewSeat->iseatnumber = ( NewSeat->prev->iseatnumber ) + 1;
// printf(" %d ", NewSeat->iseatnumber);
}

void DeleteSeat()
{
 tSEAT *LeftSeat;

 LeftSeat = tail->prev;

 LeftSeat->prev->next = LeftSeat->next;
 LeftSeat->next->prev = LeftSeat->prev;

 free(LeftSeat); 
}

void AllDeleteSeat()
{

 while(head->next != tail ) {  
  DeleteSeat();
 }

}
void PrintSeat(int nAllowed)
{
 
 int i, j;

 FILE *fpSeat;
 tSEAT *Index;

 fpSeat = fopen("도서관.txt", "wt");

 Index = (tSEAT * ) malloc ( sizeof( tSEAT) );
 Index = head->next;
 
 // 1실
 fprintf(fpSeat,"\t\t\t  ====제 1실====\n");

 for ( i = 0, j = 0 ; i < 50 ; i++) {
  
  fprintf(fpSeat,"%2d : ",i+1);

  if ( Index->iseatnumber == (i+1)) {
   fprintf(fpSeat,"%8s","OCCUPIED");
   Index = Index -> next;
  }

  else {
   fprintf(fpSeat,"%8s","EMPTY");
  }

  fprintf(fpSeat," ");

  if ( (i+1) % 5 == 0) fprintf(fpSeat,"\n");

 }

 fprintf(fpSeat,"\t\t\t  ====제 2실====\n");

 for ( i = 0 ; i < 50 ; i++) {
  
  fprintf(fpSeat,"%2d : ",i+51);

  if ( Index->iseatnumber == (i+51)) {
   fprintf(fpSeat,"%8s","OCCUPIED");
   Index = Index -> next;
  }

  else {
   fprintf(fpSeat,"%8s","EMPTY");
  }

  fprintf(fpSeat," ");

  if ( (i+51) % 5 == 0) fprintf(fpSeat,"\n");

 }

 fprintf(fpSeat,"\n");  
 
 fclose(fpSeat);
}


int PrintMenu()
{
 int iChoice;

 iChoice = 0;

 printf("================================================\n");
 printf("  1. 입실    2. 퇴실    3. 좌석정보    4. 종료  \n");
 printf("================================================\n");

 scanf("%d", &iChoice);

 return iChoice;
}

 
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호