-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw1-4.c
More file actions
48 lines (36 loc) · 978 Bytes
/
hw1-4.c
File metadata and controls
48 lines (36 loc) · 978 Bytes
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
#include <stdio.h>
#include <stdlib.h>
int main(void){
int money = 0, part = 0, delim = 0;
printf("請輸入金額: ");
scanf(" %d",&money);
if(money < 0 || money > 99999)
{
printf("輸入金額超出範圍");
return 0;
}
for( delim = 10000;delim >= 1; delim /= 10){
part = money / delim;
if(part == 0) { continue; }
switch( money / delim ) {
case 1: printf("壹"); break;
case 2: printf("貳"); break;
case 3: printf("參"); break;
case 4: printf("肆"); break;
case 5: printf("伍"); break;
case 6: printf("陸"); break;
case 7: printf("柒"); break;
case 8: printf("捌"); break;
case 9: printf("玖"); break;
}
switch( delim ) {
case 10 : printf("拾"); break;
case 100 : printf("佰"); break;
case 1000 : printf("仟"); break;
case 10000 : printf("萬"); break;
}
money -= part * delim;
}
printf("元整\n");
return 0;
}