-
Notifications
You must be signed in to change notification settings - Fork 0
/
for문 연습 2.cpp
71 lines (69 loc) · 1.04 KB
/
for문 연습 2.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
#include<stdio.h>
exam6(){
int i, count = 0,sum = 0;
for(i = 3; i<=50; i=i+3)
{
printf("%4d",i);
sum = sum + i;
++count;
if(count%5==0){
printf("\n");
}
}
printf("\n sum = %d\n",sum);
}
exam7(){
char ch;
for(ch = 'F'; ch>='A'; ch--)
{
printf("%4c",ch);
}
}
exam8(){
int i, n, fact = 1;
scanf("%d", &n);
for(i=1; i<=n; i++)
{
fact = fact * i;
}
printf("%d! = %d\n", n,fact);
}
exam9(){
int i ,dan;
printf("원하는 단은?");
scanf("%d",&dan);
printf("\n***%d단***\n",dan);
for(i=1;i<=9;i++)
{
printf("%d * %d = %d\n",dan,i,dan * i);
}
}
exam10(){
int n1,n2,i;
printf("두 수 입력 :");
scanf("%d %d",&n1,&n2);
if(n1<n2)
{
for(i=n1; i<=n2;i++)
printf("%d",i);
}
else{
for(i = n2; i<=n1; i++)
printf("%d",i);
}
}
main()
{
int no;
while(1){
printf("문제번호 : ");
scanf("%d",&no);
switch(no){
case 6: exam6(); break;
case 7: exam7(); break;
case 8: exam8(); break;
case 9: exam9(); break;
case 10: exam10(); break;
}
}
}