-
Notifications
You must be signed in to change notification settings - Fork 0
/
1125.cpp
200 lines (163 loc) · 2.86 KB
/
1125.cpp
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <stdio.h>
#include <string.h>
void exam1(){
int a[4][2];
int i,j;
int tot;
double avg;
for(i=0;i<4;i++){
printf("%d번 학생의 수학,C언어 성적 입력 : ",i+1);
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
for(i=0;i<4;i++){
tot=0;
for(j=0;j<2;j++){
tot +=a[i][j];
}
avg= tot/2.0;
printf("%d번 학생의",i+1);
printf("총점 : %3d 평균 : %.2f\n",tot,avg);
}
}
void exam2(){
int arr[5];
int max,min,i;
for(i=0;i<5;i++){
printf("입력 :");
scanf("%d",arr[i]) ;
}
max=min=arr[0];
for(i=1;i<5;i++)
{
if(max<arr[i])max=arr[i];
if(min>arr[i])min = arr[i];
printf("최다값: %d\n",max);
printf("최소값: %d\n",min);
}
}
void exam3(){
int arr[5],sum=0,i;
float avg;
for(i=0;i<5;i++){
printf("%d라운드 점수 : ",i+1);
scanf("%d",&arr[i]);
sum = arr[i]+ sum;
}
avg=sum/5;
printf("\n총점은 %d점이며,평균은%.2f점 입니다.",sum,avg);
}
void exam4(){
int i,su,snt = 0;
int b[10]={25,7,25,3,25,3,7,25,1};
printf("데이터 : ");
scanf("%d",&su);
for(i=0;i<10;i++){
if(b[i]==su)
snt=snt +1;
}
printf("%d은 %d개 있습니다\n",su,snt);
}
void exam5(){
int arr[4][5];
int i,j,cnt=1;
for(i=0;i<4;i++)
{
for(j=0;i<5;i++){
arr[i][j]=cnt ++;
}
}
for(i=0;i<4;i++)
{
for(j=0;i<5;i++){
printf("%5d",arr[i][j]);
}
}
printf("\n");
}
void exam6(){
char mark[5][5]={'\0'};
int i,j;
for(i=0;i<5;i++){
for(j=0;j<5;j++){
if(i==j||(i+j)==4)mark[i][j]='X';
}
}
for(i=0;i<5;i++){
for(j=0;j<5;j++){
printf("%c",mark[i][j]);
}
printf("\n");
}
}
void exam7(){
int data[6],i;
for(i=0;i<6;i++){
printf("정수를 입력 :");
scanf("%d",&data[i]);
}
for(i=0;i<6;i++){
printf(" %d",data[i]);
}
}
void exam8(){
char voca[50];
int len = 0;
printf("영단어 입력 :");
scanf("%s",voca);
while(voca[len])!=\0;
len++;
printf("입력한 영단어의 길이는 %d",len);
}
void exam9(){
char str[100];
int i;
gets(str);
printf("str의 문자길이 : %d\n",strlen(str));
for(int i=strlen(str);i>=0;i--)
printf("%c",str[i]);
}
void exam10(){
}
void exam11(){
}
void exam12(){
}
void exam13(){
}
void exam14(){
}
void exam15(){
}
void exam16(){
}
void exam17(){
}
main(){
int num;
while(1){
printf("\n문제번호 : ");
scanf("%d", &num);
printf("%d번 문제===========================\n", num);
switch(num){
case 1: exam1(); break;
case 2: exam2(); break;
case 3: exam3(); break;
case 4: exam4(); break;
case 5: exam5(); break;
case 6: exam6(); break;
case 7: exam7(); break;
case 8: exam8(); break;
case 9: exam9(); break;
case 10: exam10(); break;
case 11: exam11(); break;
case 12: exam12(); break;
case 13: exam13(); break;
case 14: exam14(); break;
case 15: exam15(); break;
case 16: exam16(); break;
case 17: exam17(); break;
default: return 0 ;
}
}
}