-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.33.c
110 lines (110 loc) · 1.79 KB
/
4.33.c
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
/*4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table of all
the Roman-numeral equivalents of the decimal numbers in the range 1 to 100.*/
#include <stdio.h>
int main() {
int x,a1,a2,a3,a4;
printf("Sayıyı giriniz(1-1000): ");
scanf("%d",&x);
a1=x%10;
a2=(x-a1)%100;
a3=(x-a1-a2)%1000;
a4=(x-a1-a2-a3)%10000;
if (a4==1) {
printf("M-" );
}
switch (a3) {
case 100:
printf("C");
break;
case 200:
printf("CC");
break;
case 300:
printf("CCC");
break;
case 400:
printf("CD");
break;
case 500:
printf("D");
break;
case 600:
printf("DC");
break;
case 700:
printf("DCC");
break;
case 800:
printf("DCCC");
break;
case 900:
printf("CM");
break;
}
if (a3!=0 && (a2!=0||a1!=0)) {
printf("-");
}
switch (a2) {
case 10:
printf("X");
break;
case 20:
printf("XX");
break;
case 30:
printf("XXX");
break;
case 40:
printf("XL");
break;
case 50:
printf("L");
break;
case 60:
printf("LX");
break;
case 70:
printf("LXX");
break;
case 80:
printf("LXXX");
break;
case 90:
printf("XC");
break;
}
if (a2!=0 && a1!=0) {
printf("-" );
}
switch (a1) {
case 1:
printf("I");
break;
case 2:
printf("II");
break;
case 3:
printf("III");
break;
case 4:
printf("IV");
break;
case 5:
printf("V");
break;
case 6:
printf("VI");
break;
case 7:
printf("VII");
break;
case 8:
printf("VIII");
break;
case 9:
printf("IX");
break;
}
printf("\n" );
return 0;
}