- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
package mypackage;
import java.io.*;
public class ArabToRim{
public static void main(String arg[]){
String RimSym[] ={"I", "V", "X", "L","C","D","M"} ;
String Arab = "";
System.out.println("Input simbol");
try {
BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
Arab = d.readLine();
} catch (IOException e) {
System.out.println("Input ERROR");
}
Arab = new StringBuilder(Arab).reverse().toString();
String Rim = "";
String rez = "";
int n = 0;
int c = 0;
int i = 0;
for(int k=Arab.length();k>0; --k){
int s = Character.getNumericValue(Arab.charAt(c));
rez = "";
if (s<=3) {
for (i=s; i>0; --i){
rez=rez + RimSym[n];
}
}
if (s==4) {
rez=rez + RimSym[n]+RimSym[n+1];
}
if (s==5) {
rez=rez + RimSym[n+1];
}
if (s>=6) {
if (s<9){
rez=rez + RimSym[n+1];
for (i=s-5; i>0; --i){
rez=rez + RimSym[n];
}
}
}
if (s==9) {
rez=rez + RimSym[n]+ RimSym[n+2];
}
++c;
n = n+2;
Rim=rez+Rim;
}
System.out.println(Rim);
}
}
guest 20.03.2015 19:47 # +7
for(int k=Arab.length();k>0; --k){
кручу верчу наебать хочу