C언어로 이용할수 있는_프로그램
본 자료는 7페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
해당 자료는 7페이지 까지만 미리보기를 제공합니다.
7페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

C언어로 이용할수 있는_프로그램에 대한 보고서 자료입니다.

목차

1.로또 프로그램

2.가위바위보 게임

3.주사위 프로그램

4.달력프로그램

5.성적 계산프로그램

6. 가계부 프로그램

본문내용

mo[MAX]; // 구조체 선언(100개를 저장할수 있는 가계부)
int total; // 전체 금액
//----- MAIN부분
void main()
{
//---- 파일을 오픈
fnOpen();
//----- 메 뉴
fnMenu();
//---- 종 료
fnExit();
//---- 파일에 저장
fnSave();
}
void fnMenu()
{
int choice; // 메뉴선택 변수
while(1)
{
system(\"cls\"); // 화면을 지운다
printf(\"┏━━━━━━━━━━━━━━━━━━━━━━━┓ \\n\");
printf(\"┃ [1]입력 [2]지출 [3]수입 [4]전체출력 [5]종료 ┃ \\n\");
printf(\"┗━━━━━━━━━━━━━━━━━━━━━━━┛ \\n\");
printf(\"CHOICE : [ ]\\b\\b\\b\"); scanf(\"%d\",&choice);
switch(choice)
{
case 1 : fnInput(); break;
case 2 : fnDisburse(); break;
case 3 : fnIncome(); break;
case 4 : fnPrint(); break;
case 5 : return;
}
system(\"pause\"); // 화면을 멈추는 기능
}
}
//---- 가계부를 작성하는 부분
void fnInput()
{
int i;
int choice;
for(i=0; i {
if(mo[i].day == 0 )
{
printf(\"---------------[%d] \\n\",i);
printf(\"Year : \" ); scanf(\"%d\" , &mo[i].year);
printf(\"Month : \" ); scanf(\"%d\" , &mo[i].month);
printf(\"Day : \" ); scanf(\"%d\" , &mo[i].day);
printf(\"[1] 수입 [2]지출 : \"); scanf(\"%d\", &choice);
if(choice == 1)
{
mo[i].flag = 1 ;
printf(\"수입입력 : \");
scanf(\"%d\" , &mo[i].money);
total+=mo[i].money;
break;
}
else if(choice == 2)
{
mo[i].flag = 2;
printf(\"지출 입력 : \");
scanf(\"%d\",&mo[i].money);
total-=mo[i].money;
break;
}
else
{
printf(\"선택을 잘못 하셨습니다 \\n\");
return;
}
}
}
printf(\"정상적으로 입력되었습니다 \\n\");
}
//---- 지출부분 출력
void fnDisburse()
{
int i;
for(i=0 ; i {
if(mo[i].flag == 2)
{
printf(\"----------------[%d] \\n\", i);
printf(\"%4d년 %2d월 %2d일\\n\", mo[i].year , mo[i].month , mo[i].day);
printf(\"지출 : -%d원 \\n\", mo[i].money);
}
}
printf(\"\\n******** 현재 총액 : %d 원 *********\\n\", total);
}
//---- 수입부분 출력
void fnIncome()
{
int i;
for(i=0 ; i {
if( mo[i].flag == 1 )
{
printf(\"----------------[%d] \\n\", i);
printf(\"%4d년 %2d월 %2d일\\n\", mo[i].year , mo[i].month , mo[i].day);
printf(\"수입 : %d원 \\n\", mo[i].money);
}
}
printf(\"\\n******** 현재 총액 : %d 원 *********\\n\", total);
}
//----- 전체출력하는 부분
void fnPrint()
{
int i;
for(i=0 ; i {
if(mo[i].day != 0)
{
printf(\"----------------[%d] \\n\", i);
printf(\"%4d년 %2d월 %2d일\\n\", mo[i].year , mo[i].month , mo[i].day);
if(mo[i].flag==0) { printf(\"\\t지출 : -%d원 \\n\", mo[i].money); }
else { printf(\"\\t수입 : %d원 \\n\", mo[i].money); }
}
}
printf(\"\\n******** 현재 총액 : %d 원 *********\\n\", total);
}
//---- 프로그램 종료
void fnExit()
{
system(\"cls\"); // 화면을 지운다
printf(\"┏━━━━━━━━━━━━━━━━━━━━━━━┓ \\n\");
printf(\"┃ **** 가계부 프로그램을 종료합니다 **** ┃ \\n\");
printf(\"┗━━━━━━━━━━━━━━━━━━━━━━━┛ \\n\");
}
//---- 저 장
void fnSave()
{
FILE *fp;
int i;
if( (fp = fopen(\"file.txt\", \"wb\")) == NULL)
{
printf(\"파일 저장에 실패하였습니다 \\n\");
exit(1);
}
fwrite( &total , sizeof(int) , 1 , fp);
for(i=0 ; i {
if(mo[i].day != 0)
{
fwrite( &mo[i] , sizeof(MONEY) , 1, fp);
}
}
printf(\"파일에저장 : Saving\");
for(i=0 ; i<5 ; i++)
{
Sleep(400);
putchar(\'.\');
}
putchar(\'\\n\');
fclose(fp);
}
//----- 파일을 오픈
void fnOpen()
{
FILE *fp;
int i;
if( (fp = fopen(\"file.txt\", \"rb\")) == NULL)
{
printf(\"프로그램을 처음으로 시작합니다 \\n\");
return;
}
fread(&total , sizeof(int) ,1 , fp);
for(i=0 ; !feof(fp) ; i++)
{
fread( &mo[i] , sizeof(MONEY) , 1, fp);
}
fclose(fp);
}
  • 가격1,500
  • 페이지수20페이지
  • 등록일2009.03.06
  • 저작시기2008.3
  • 파일형식한글(hwp)
  • 자료번호#521809
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니