Decimal 2 Roman Dev C++

Berikut adalah kode program yang dapat memberikan keluaran Decimal 2 Roman, kode bisa digunakan pada aplikasi Dev C++ ataupun aplikasi program bahasa C lainnya. Bagi anda yang belum mempunyai Dev C++, bisa di download di Download Dev C++, lalu silakan di install.

#include <iostream>

using namespace std;

int main(){

unsigned long long int c=0, b;

for(unsigned long long int n=1; ; n++){
c=n;
cout<<" "<<n<<" = ";

while(c>=1000000){
cout<<"m";
c=c-1000000;
}
while(c>=100000){
if(c>=500000){
if(c>=900000){cout<<"cm"; c=c-900000;}
else{
cout<<"d";
c=c-500000;
}
}
else{
if(c>=400000){cout<<"cd"; c=c-400000;}
else{
cout<<"c";
c=c-100000;
}
}
}
while(c>=10000){
if(c>=50000){
if(c>=90000){cout<<"xc"; c=c-90000;}
else{
cout<<"l";
c=c-50000;
}
}
else{
if(c>=40000){cout<<"xl"; c=c-40000;}
else{
cout<<"x";
c=c-10000;
}
}
}
while(c>=1000){
if(c>=5000){
if(c>=9000){cout<<"Mx"; c=c-9000;}
else{
cout<<"v";
c=c-5000;
}
}
else{
if(c>=4000){cout<<"Mv"; c=c-4000;}
else{
cout<<"M";
c=c-1000;
}
}
}
while(c>=100){
if(c>=500){
if(c>=900){cout<<"CM"; c=c-900;}
else{
cout<<"D";
c=c-500;
}
}
else{
if(c>=400){cout<<"CD"; c=c-400;}
else{
cout<<"C";
c=c-100;
}
}
}
while(c>=10){
if(c>=50){
if(c>=90){cout<<"XC"; c=c-90;}
else{
cout<<"L";
c=c-50;
}
}
else{
if(c>=40){cout<<"XL"; c=c-40;}
else{
cout<<"X";
c=c-10;
}
}
}
while(c>=1){
if(c>=5){
if(c==9){cout<<"IX"; c=c-9;}
else{
cout<<"V";
c=c-5;
}
}
else{
if(c==4){cout<<"IV"; c=c-4;}
else{
cout<<"I";
c=c-1;
}
}
}
cout<<endl;
}
}

Dengan Hasil running :

Rich Snippets
Published
Article
Decimal 2 Roman Dev C++
Ratings
51star1star1star1star1star

Kata Bijak? Google banyak!

You may also like...

1 Response

  1. Faiq Fajar says:

    Mantap

Leave a Reply