단어 정리 프로그램 - dan-eo jeongli peulogeulaem

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

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<ctype.h>

#include<windows.h>

//단어장 프로그램

typedef struct information {

int num;

char word[100];

char first_word;

struct information *next;

} txt;

void memory(txt a[],int i);//기억

void output(txt a[]);//불러오기

void all_word(txt a[],int num);//전체보기

void new_view();//새창으로

int main()

{

int butten;

txt dic[100];

int num = 0;

do

{

puts("--------------------------------------------------");

puts("1:단어기억 2:단어검색 3:전체보기 4:새창보기 5:종료");

puts("--------------------------------------------------");

puts("");

do

{

printf("버튼 : ");

scanf("%d"&butten);

if (butten < 1 || butten>5)

puts("버튼를 잘못입력하셨습니다.");

while (butten < 1 || butten>5);

switch (butten)

{

case 1:

memory(dic, num);

num++;

break;

case 2:

output(dic);

break;

case 3:

all_word(dic, num);

break;

case 4:

new_view();

break;

default:

break;

}

while (butten!=5);

return 0;

}

void memory(txt a[],int i)//기억

{

//txt *p = NULL;

//p = a + i;

printf("단어를 입력하시오.\n");

scanf("%s", a[i].word/* *p->word*/);

//(*p).num = i + 1;

a[i].num = i + 1;

//(*p).first_word = (*p).word[0];

a[i].first_word = a[i].word[0];

a[i].next = NULL;

printf("%s 이(가) 저장되었습니다.\n",a[i].word);

puts("");

}

void output(txt a[])//단어검색

{

char key[100= "";

int i = 0;

int key_code = 0;

//txt *p1 = NULL;

//char *p2 = NULL;

//p1 = a + i;

//p2 = key;

printf("찾을 단어를 입력하시오.\n");

scanf("%s", key/* p2*/);

for (i = 0; i < 100; i++)

{

if (strcmp(/*(*p1)*/a[i].word, key/* p2*/== 0)

{

printf("번호 : %d / 단어 : %s / 알파벳 : %c\n", a[i].num, a[i].word, a[i].first_word);

//printf("번호 : %d / 단어 : %s / 알파벳 : %c\n", p1->num, p1->word, p1->first_word);

key_code++;

}

}

if (key_code == 0)

puts("해당 단어를 찾지 못했습니다.");

puts("");

}

void all_word(txt a[],int num)//전체보기

{

puts("");

txt *first = NULL;

txt *current = NULL;

for (int i = 0; i < num; i++)

{

first = a + i;

a[i].next = a + 1;

printf("번호 : %d / 단어 : %s / 알파벳 : %c\n", first->num, first->word, first->first_word);

/*

        current = first;

        //puts(" 번호 :  단어  : 알파벳");

        while (current != NULL)

        {

            printf("번호 : %d / 단어 : %s / 알파벳 : %c", current->num, current->word, current->first_word);

            current = current->next;

        }*/

}

printf("총 %d개의 단어가 저장되어 있습니다.\n", num);

puts("");

}

void new_view()//새창으로

{

system("cls");

}

cs