3 like 0 dislike
2.3k views
請寫一個程式,把輸入的阿拉伯數字轉成羅馬數字輸出。

羅馬數字的規則請參考

https://zh.wikipedia.org/wiki/%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97

輸入說明:

會輸入一個不超過1000的正整數

輸出說明:

請將相對於輸入數字的羅馬數字輸出

輸入範例:

14

輸出範例:

XIV
[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (18k points)
ID: 34979 - Available when: Unlimited - Due to: Unlimited
| 2.3k views

6 Answers

0 like 0 dislike
Hidden content!
* ** * *
* * * * * **
int did(char a)
{
* ** * * * ** **** **** * *** * * * 1;
** * ** ** ** if(a=='V') return 5;
* ***** ** *** * ** if(a=='X') return 10;
* * ** ***** * * return 50;
** ** * ** * ** ** *** * return 100;
*** * ** * * * ** * * * return 500;
**** **** * * ** return 1000;
** ** * *
** * * ** * ** ** * * 0;
}
int main()
{
* ** * int len,SUM1;
** ** int sum;
*** ** char s[1101];
** * * * * * * ** **** * *
* * * ** * {
*** ** * * * * ** * * *** sum = SUM1 = 0;
* * ** ** *** * * **** * len = * ** * *
**** **** * *** * * for(int i ***** ***** ** *
** *** **** * ** * * {
*** * ** * *** ** * * ** ** *** * *
* * ** * ** * * *** * * *** *** ***** * * *** * ** ** += SUM1;
* * * * * * * ***
** * * ** * * ** ** * }
*** * * ** * *** * * ****** * * ** *
**** * * }
***** **** ** ***** **** * * *** *
}
answered by (236 points)
0 0
prog.c: In function 'main':
prog.c:5:1: error: stray '\343' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
 ^
prog.c:5:2: error: stray '\200' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
  ^
prog.c:5:3: error: stray '\200' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
   ^
prog.c:5:4: error: stray '\343' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
    ^
prog.c:5:5: error: stray '\200' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
     ^
prog.c:5:6: error: stray '\200' in program
 \xe3\x80\x80\xe3\x80\x80char a[4002],b[4002];
      ^
prog.c:6:15: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[4002]' [-Wformat=]
 while(scanf("%s",&a)!=EOF)
               ^
prog.c:10:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[4002]' [-Wformat=]
 scanf("%s",&b);
         ^
prog.c:136:9: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
 int sum=abs(suma-sumb);
         ^~~
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
*** ***** * *** *

int main()
{
* ****** * * ** ** *** a,i;
* * * * * * ** **
* ** ** ** ** ** **** * * * * *** * *
** **** **** * **
** * ** *** * *
* * * ** ** * ***** ** * * ** * ** ** **
** * * ***** **** *
** **** * **** ** * *** * ****
***** * * * *** **** ** *** * ***** ***
    }    
* *** ***** * * * * *** if(a==4)
** * **** * * ** *** * ***
* ** ***** * **** * * ** * ** * ****
* ** * ** ****** * * *
    printf("V");
    *** *** * * * * *** **
*** *** ** *** * ***
* * * *** ** ** * * ** ** * ***
** **** ** * * ********* * **** ** ** *
    }
    }
    else if(a==9)
* * * * ** ******** *** ***** * * **
** * * ** * * ** * * if(a==10)
** * * ** ** * * *** * ***** * * *
*** *** **** ** *** * * if(a==50)
** ** ** ** * * * ** * * ***
*** * * * * * *** ** * * if(a==100)
* *** ** *** ** * * *** **** * *
** * *** ***** ******* ** if(a==500)
* ** ** ****** * * *** ** ******** * ******
*** * ** * * ** * if(a==1000)
*** ** *** ** ***** ** * * ** ***
****** * * ** *** ** *
   
    return 0;
}
answered by (215 points)
edited by
0 0
prog.c:1:1: error: expected identifier or '(' before '.' token
 .
 ^
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
*** ** ***** **
int main()
{
char *th[] = { ** * *** * ** ** **
char *hun[] = { ** *** *** ** ** * ** * *** * *** * ** * * *** * **** * * *** ** * *** * * **** * ****** ** **** * * * ** ***** **** ** * ** };
char *ten[] = { * *** ** *** *** * * ** *** *** ** ***** ** *** * ***** * * ** ** * * ** ** *** * ** *** ** * * * * ** * ** ** };
char *one[] = { * * * ** * ** * ***** ***** ** * * ** * *** **** ** ************** *** * ** * * * ***** **** * * ********* * **** ** * * ** ** * *** };
int input;

while( scanf( ** * *** * * * ** ) != EOF )
*** * *** * **** *** * th[ * * ** ], hun[ * ** * * ], ten[ * * * ], one[ ** ] ); **** *
* 0;
}
answered by (100 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
***** *** * **** * * *


int main()
{
char * * ** = { ******** ** ** * ** *** * ** ***** **** ** ** *** };
char * * * = { ** * ** * * * *** * *** * * * * ** * **** * ** ** ** **** ** ** ** * ** * * ***** *** *** *** * * ** * **** * *** * ** * ** };
char *ten[] = { ** * **** * * * **** *** * *** ** * * ** ** **** * ** **** ** ** * * *** * * ********* * * * *** ** * * ** ** * * };
char *one[] = { ** ******* ** * ***** ** * ** * * * * ** * * **** **** * ** * ** * ** * * ********** * * **** * *** ** ** ** * ** *** };

int input;

** * * * ** * * * * ** *** );
printf( * ** * **** thousand[ * **** ], hundred[ ** ** ], ten[ * * * ** ], one[ input%10 ] );

return 0;
}
answered by (174 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
*** **** * *****
int main()
{

**** * * * * char * ** = { *** ** **** * ** ** * * * * *** * ** *** ***** * };
** ** * char * *** = { *** * *** *** *** * * ** ***** * *** ** **** ** **** * **** ** ** *** ** * ** * * * **** * *** ** * * ** ****** * };
* * * * char *ten[] = { * * * ** ***** * * *** ** ** * * ** ** * * * *** **** ** * * ** * ***** *** * * ** ** * * *** * ** * ** ** **** };
** * ** **** char *one[] = { * ******* * * ** * * * ** * ** * ** *** * *** * ** * * * ** ** ****** ** * ** * **** * *** * * ** * ****** * * * * * ** * * };

* * * ** * int n;

* * **** while( scanf( *** ** ** * * ** ) != EOF )
* * **** ** printf( * * *** ** ** ** * n/1000 ], hundred[ ******* ], ten[ ******* ], one[ n%10 ] );

return 0;
}
answered by (160 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
#include ** *** *****


int main()
{

**** * * ** *** * * * thousand[2][5]={ *** * ** * ** * };
* * *** * * ** **** * hundred[10][5]={ * ***** ** *** ** ***** ** * * * ** ****** * * ******** **** ***** * ** * * * **** ** ** * * * * ** * *** ** *** * };
* * ** *** **** * *** * ten[10][5]={ * * * *** *** *** * * ** * * * * *** ***** * * ***** ** ******* * * * *** ****** ** * * ** * * *** ** *** ** * * * };
* ** *** ***** ** ** * one[10][5]={ * * ** * * ** * **** **** * *** ** *** ** * * ** ** * ** * ** * * *** * ***** **** ** ***** * ** ** ** ** * * * *** * };

****** * ***** * ** ***** * * input;
** ** * * ** ** ** * * ** scanf( *** ** ** ** * &input ) != EOF )
* * ** ** ** * ** * ** *** * ** ** * * * * * *** *** thousand[ input/1000 ], hundred[ (input/100)%10 ], ten[ (input/10)%10 ], one[ input%10 ] );

**** * * * * **** * * ** 0;

}
answered
0 0
Case 0: Correct output
Case 1: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.230.2
©2016-2025

Related questions

3 like 0 dislike
5 answers
[Exercise] Coding (C) - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 34978 - Available when: Unlimited - Due to: Unlimited
| 2.3k views
3 like 0 dislike
20 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33758 - Available when: Unlimited - Due to: Unlimited
| 5.7k views
3 like 0 dislike
14 answers
[Exercise] Multichoice - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 34985 - Available when: 2017-11-30 14:00 - Due to: 2017-11-30 14:30
| 1.9k views
2 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33762 - Available when: Unlimited - Due to: Unlimited
| 6.2k views
3 like 0 dislike
22 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33757 - Available when: Unlimited - Due to: Unlimited
| 7.2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users