
-
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


본문내용
brary[], 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;
}
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;
}
추천자료
B2C에 관한 연구(PPT,파워포인트)
[정보통신] c프로그래밍
AOL의 4C마케팅
C언어 개요
주스안에 있는 비타민 C 정량
민원서비스 혁신(G4C) 시스템
전자상거래 6c전략 비교분석 (삼성증권 현대증권)
KPI-C (한국아동인성검사) 발표자료
Vitamin C정성실험
[c언어] C 언어 입문
[16C][16세기][도교][문학][구개음화]16C(16세기)의 도교, 16C(16세기)의 문학, 16C(16세기)...
[15C][15세기][소화문헌][협주][구결][분철][부사][파생어][문헌]15C(15세기)의 소화문헌, 15...
[21C]21C(21세기)의 리더십(리더쉽), 21C(21세기)의 사회변화, 21C(21세기)의 기업조직, 21C(...
동서양고전의이해C형 2017-자신의 유형에 속한 책들 중 한 권을 선택하여 읽은 후, 과제를 작...
소개글