c언어콘서트_ 프로그래밍 Programming 2장~11장
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
해당 자료는 10페이지 까지만 미리보기를 제공합니다.
10페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

c언어콘서트_ 프로그래밍 Programming 2장~11장에 대한 보고서 자료입니다.

본문내용

ary[], int count);
void menu();
int get_input();
void search_record(BOOK library[], int count);
void print_record(BOOK library[], int count);
void sort_record(BOOK library[], int n);
int main(void)
{
int num, count = 0;
BOOK library[30] = {'\0'};
while(1)
{
menu();
num = get_input();
switch(num)
{
case 1:
add_record(library, count);
count++;
continue;
case 2:
print_record(library, count);
continue;
case 3:
search_record(library, count);
continue;
case 4:
return -1;
}
return 0;
}
}
void add_record(BOOK library[], int count)
{
int type;
fflush(stdin);
printf("제목:");
gets(library[count].title);
printf("저자:");
gets(library[count].author);
printf("위치:");
gets(library[count].location);
printf("장르(0: 만화, 1: 공상소설, 2: 소설, 3: 고전)");
scanf("%d",&type);
if(type >= 0 && type <= 3)
library[count].genre = type;
else
library[count].genre = COMIC;
}
void menu()
{
printf("====================\n");
printf(" 1. 추가\n");
printf(" 2. 출력\n");
printf(" 3. 검색\n");
printf(" 4. 종료\n");
printf("====================\n");
}
int get_input()
{
int num;
printf("정수값을 입력하시오 : ");
scanf("%d",&num);
return num;
}
void search_record(BOOK library[], int count)
{
int i;
char title[TITLE_SIZE];
fflush(stdin);
printf("제목: ");
gets(title);
for(i = 0; i < count; i++)
{
if(strcmp(title,library[i].title) == 0)
{
printf("저장된 위치는 %s\n",library[i].location);
return;
}
}
printf("찾는 책이 테이블에 없습니다.\n");
}
void print_record(BOOK library[], int count)
{
int i;
fflush(stdin);
for(i = 0; i < count; i++)
{
printf("제목 : %s\n",library[i].title);
printf("저자 : %s\n",library[i].author);
printf("위치 : %s\n",library[i].location);
if(library[i].genre == 0)
printf("장르 : 코믹\n");
else if(library[i].genre == 1)
printf("장르 : 공상과학\n");
else if(library[i].genre == 2)
printf("장르 : 소설\n");
else if(library[i].genre == 3)
printf("장르 : 고전\n");
}
}
7.
#include
enum game { scissor, rock, paper };
int main(void)
{
enum game computer=scissor;// 가위
enum game user=scissor;
printf("가위(0), 바위(1), 보(2)를 입력하세요: ");
scanf("%d", &user);
if( user == scissor )
printf("비겼습니다.\n");
else if( user == rock )
printf("컴퓨터가 졌습니다.\n");
else
printf("컴퓨터가 이겼습니다.\n");
return 0;
}
8.
#include
#include
enum shape_type { TRIANGLE, RECTANGLE, CIRCLE };
struct shape {
int type;
union {
struct {
int base, height;
} tri;
struct {
int width, height;
} rect;
struct {
int radius;
} circ;
} p;
};
int main(void)
{
struct shape s;
enum shpae_type type;
printf("도형의 타입을 입력하시오(0, 1, 2): ");
scanf("%d", &type);
switch(type){
case TRIANGLE:
printf("밑변과 반지름을 입력하시오(예를 들어서 100 200): ");
scanf("%d %d", &s.p.tri.base, &s.p.tri.height);
printf("면적은 %d\n", (int)(0.5*s.p.tri.base*s.p.tri.height));
break;
case RECTANGLE:
printf("가로와 세로의 길이를 입력하시오(예를 들어서 100 200):");
scanf("%d %d", &s.p.rect.width, &s.p.rect.height);
printf("면적은 %d\n", (int)(s.p.rect.width*s.p.rect.height));
break;
case CIRCLE:
printf("반지름을 입력하시오(예를 들어서 100): ");
scanf("%d", &s.p.circ.radius);
printf("면적은 %d\n", (int)(3.14*s.p.circ.radius*s.p.circ.radius));
break;
}
return 0;
}
  • 가격3,000
  • 페이지수63페이지
  • 등록일2014.11.14
  • 저작시기2012.4
  • 파일형식한글(hwp)
  • 자료번호#950217
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니