Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <stdlib.h>
- int hasil;
- using namespace std;
- void kali(){
- int i,x;
- cout<<"input:"; cin>>i;
- for (int a=1;a<=i;a++){
- for (int b=1;b<=i;b++){
- x=a*b;
- cout<<setw(4)<<x<<" "<<setw(4);;
- }
- cout<<endl;
- }}
- void pangkat(){
- int basis,pangkat,b;
- cout<<"basis:";cin>>basis;
- b=basis;
- cout<<"pangkat:";cin>>pangkat;
- for(int i=1;i<pangkat;i++){
- b=b*basis;
- }cout<<"hasil :\n"<<b;
- hasil=b;
- }
- void satuan (int a)
- {
- if (a==1) {
- cout<<" Satu ";
- }
- else if (a==2) {
- cout<<" Dua ";
- }
- else if (a==3) {
- cout<<" Tiga ";
- }
- else if (a==4) {
- cout<<" Empat ";
- }
- else if (a==5) {
- cout<<" Lima ";
- }
- else if (a==6) {
- cout<<" Enam ";
- }
- else if (a==7) {
- cout<<" Tujuh ";
- }
- else if (a==8) {
- cout<<" Delapan ";
- }
- else if (a==9) {
- cout<<" Sembilan ";
- }
- else if (a==10) {
- cout<<" Sepuluh ";
- }
- else if (a==11) {
- cout<<" Sebelas ";
- }}
- void terbilang (int b)
- {
- if (b<=11) {
- satuan(b);
- }
- else if ((b>11) && (b<=19)) {
- terbilang(b%10);
- cout<<"Belas ";
- }
- else if ((b>=20)&&(b<=99)) {
- terbilang(b/10);
- cout<<"Puluh";
- terbilang(b%10);
- }
- else if ((b>=100)&&(b<=199)) {
- cout<<"Seratus";
- terbilang(b%100);
- }
- else if ((b>=200)&&(b<=999)) {
- terbilang(b/100);
- cout<<"Ratus";
- terbilang(b%100);
- }
- else if ((b>=1000)&&(b<=1999)) {
- cout<<"Seribu";
- terbilang(b%1000);
- }
- else if ((b>=2000)&&(b<=9999)) {
- terbilang(b/1000);
- cout<<"Ribu";
- terbilang(b%1000);
- }}
- main(){
- char ulang;
- bool a=false;
- int i;
- do{
- cout<<"MENU\n";
- cout<<"1.PERULANGAN\n2.PEMANGKATAN\n3.HASIL PEMANGKATAN\n4.Exit\n";
- cout<<"PILIH :";cin>>i;
- switch (i){
- case 1:
- kali();
- break;
- case 2:
- pangkat();
- a=true;
- break;
- case 3:
- cout<<"Hasil Pemangkatan\n";
- if (a==false)
- cout<<"pilih dua dulu";
- else
- {if (hasil==0)
- cout<<"Nol\n";
- else
- {
- terbilang(hasil);
- }
- }
- break;
- case 4 :
- exit(0);
- }
- cout<<"\nKembali ke Menu?[y/n]:";cin>>ulang;}
- while (ulang=='y' || ulang=='Y');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement