Advertisement
oke_google

Mengubah angka menjadi huruf

Dec 12th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. void griko3()
  7. {
  8.     char input[100];
  9.     int kounter, angka, i, n;
  10.     cout<<"Masukan Angka = ";
  11.     cin.getline(input, 100);
  12.     angka=strlen(input);
  13.     for(kounter=0; input[kounter]!='\0'; kounter++)
  14.     {
  15.         if(input[kounter]!=' ')
  16.         {
  17.             if(input[kounter+1]>='0' && input[kounter+1]<='9')
  18.             {
  19.                 (input[kounter]=='1' ? n=9 : n=18);
  20.                 input[kounter]=char (input[kounter]+input[kounter+1]+n);
  21.                 input[kounter+1]=' ';
  22.                 for(i=kounter; i<=angka; i++)
  23.                 {
  24.                     input[i+1]=input[i+2];
  25.                 }
  26.             }
  27.             else
  28.             {
  29.                 input[kounter]=char(input[kounter]+48);
  30.             }
  31.         }
  32.     }
  33.     cout<<input;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement