Kamis, 01 Desember 2016

Jawabannya No 2

Soal no 2 nya kawan :) ig:mdputra.dk // line:madeputra27

#include <iostream>
#include <conio.h>
#include <math.h>
int angka;

void small(int satuan)
{
 if (satuan==1)
 cout<<" Satu";
 else
 if (satuan==2)
 cout<<" Dua";
 else
 if (satuan==3)
 cout<<" Tiga";
 else
 if (satuan==4)
 cout<<" Empat";
 else
 if (satuan==5)
 cout<<" Lima";
 else
 if (satuan==6)
 cout<<" Enam";
 else
 if (satuan==7)
 cout<<" Tujuh";
 else
 if (satuan==8)
 cout<<" Delapan";
 else
 if (satuan==9)
 cout<<" Sembilan";
 else
 if (satuan==10)
 cout<<" Sepuluh";
 else
 if (satuan==11)
 cout<<" Sebelas";
}

void big(int up){
 if (up<=11){
 small(up);
 }
 else if (up>=12 && up<=19){
 big(up%10);
 cout<<" Belas";
 }
 else if (up>=20 && up<=99){
 big(up/10);
 cout<<" Puluh";
 big(up%10);
 }
 else if (up>=100 && up<=199){
 cout<<" Seratus";
 big(up%100);
 }
 else if (up>=200 && up<=999){
 big(up/100);
 cout<<" Ratus";
 big(up%100);
 }
 else if (up>=1000 && up<=1999){
 cout<<" Seribu";
 big(up%1000);
 }
 else if (up>=2000 && up<=9999){
 big(up/1000);
 cout<<" Ribu";
 big(up%1000);
 }
 else if (up>=10000 && up<=11999){
 big(up/1000);
 cout<<" Ribu";
  big(up%1000);
 }
 else if (up>=12000 && up<=19999){
 big(up/1000);
 cout<<" Ribu";
 big(up%1000);
 }
 else if (up>=20000 && up<=99999){
 big(up/1000);
 cout<<" Ribu";
 big(up%1000);
 }
 else if(up>=100000 && up<=999999){
 big(up/1000);
 cout<<" Ribu";
 big(up%1000);
 }

}

int main(){
 ulang:
 cout<<"Masukkan Angka: ";
 cin>>angka;
 if(angka>=1000000){
 cout<<"Maksimal 999999"<<endl<<endl;
 goto ulang;
 }
 cout<<"Terbilang: ";
 if (angka==0)
 cout<<"Nol";
 else
 big(angka);
 getch();
}

Tidak ada komentar:

Posting Komentar