Advertisement
oke_google

Modul 3.15

Dec 2nd, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char input[100], kopi[100], kopi2[100];
  8.     int kounter;
  9.     int vokal=0;
  10.     int konsonan=0;
  11.     int besar=0;
  12.     int kecil=0;
  13.     int gang=0, offset, gantine, banyak=1, angka, i, pluss=0, pertama=0, kedua;
  14.     cout<<"Input User       = ";
  15.     cin.getline(input, 100);
  16.     for(kounter=0; input[kounter]!='\0'; kounter++)
  17.     {
  18.         if(input[kounter]>='A' && input[kounter]<='z' || input[kounter]==' ')
  19.         {
  20.             banyak++;
  21.         }
  22.     }
  23.     angka=banyak;
  24.     for(kounter=0; kounter<angka; kounter++)
  25.     {
  26.         kopi[kounter]=input[kounter];
  27.     }
  28.     cout<<endl;
  29.     cout<<"Input Text       = "<<input<<endl;
  30.     cout<<"Reserved         =";
  31.     for(kounter=angka-1; kounter>=0; kounter--)
  32.     {
  33.         cout<<kopi[kounter];
  34.     }
  35.     cout<<endl;
  36.     for(kounter=0; kounter<angka; kounter++)
  37.     {
  38.         kopi[kounter]=input[kounter];
  39.     }
  40.     cout<<"Reserved         = ";
  41.     for(kounter=0; kounter<angka; kounter++)
  42.     {
  43.             if(kopi[kounter]==' ' || kounter==angka-1){
  44.                 kedua=kounter;
  45.                 int x=0;
  46.                 for(i=pertama; i<kedua; i++){
  47.                     cout<<kopi[kedua-1-x];
  48.                     x++;
  49.                     if(i==kedua-1){
  50.                         pertama=kounter+1;
  51.                         cout<<" ";
  52.                     }
  53.                 }
  54.             }
  55.     }
  56.     cout<<endl;
  57.     for(kounter=0; kounter<angka; kounter++)
  58.     {
  59.         kopi[kounter]=input[kounter];
  60.     }
  61.     cout<<endl;
  62.     for(kounter=0; kounter<angka; kounter++)
  63.     {
  64.         if(kopi[kounter]>='a' && kopi[kounter]<='z')
  65.         {
  66.             kopi[kounter]=char(kopi[kounter]-32);
  67.         }
  68.     }
  69.     cout<<endl;
  70.     cout<<"All Uppercase    = "<<kopi<<endl;
  71.     for(kounter=0; kounter<angka; kounter++)
  72.     {
  73.         if(kopi[kounter]>='A' && kopi[kounter]<='Z')
  74.         {
  75.             kopi[kounter]=char(kopi[kounter]+32);
  76.         }
  77.     }
  78.     cout<<"All Lowercase    = "<<kopi<<endl;
  79.         for(kounter=0; kounter<angka; kounter++)
  80.     {
  81.         kopi[kounter]=input[kounter];
  82.     }
  83.     for(kounter=0; kounter<angka; kounter++)
  84.     {
  85.         kopi2[kounter]=input[kounter];
  86.     }
  87.     for(kounter=0; kounter<angka; kounter++)
  88.     {
  89.         if(kopi[kounter]>='A' && kopi[kounter]<='Z')
  90.         {
  91.             kopi[kounter]=' ';
  92.         }
  93.         else if(kopi2[kounter]>='a' && kopi2[kounter]<='z')
  94.         {
  95.             kopi2[kounter]=' ';
  96.         }
  97.     }
  98.     cout<<endl;
  99.     cout<<"Hide Uppercase   = "<<kopi<<endl;
  100.     cout<<"Hide Lowercase   = "<<kopi2<<endl<<endl;
  101.     for(kounter=0; kounter<angka; kounter++)
  102.     {
  103.         if(input[kounter]>='A' && input[kounter]<='Z')
  104.         {
  105.             besar++;
  106.         }
  107.         else if(input[kounter]==' ')
  108.         {
  109.             gang=0;
  110.         }
  111.         else
  112.         {
  113.             kecil++;
  114.         }
  115.     }
  116.     cout<<endl;
  117.     cout<<"Total Uppercase  = "<<besar<<endl;
  118.     cout<<"Total LowerCase  = "<<kecil-1<<endl;
  119.     for(kounter=0; kounter<angka; kounter++)
  120.     {
  121.         kopi[kounter]=input[kounter];
  122.     }
  123.     for(kounter=0; kounter<angka; kounter++)
  124.     {
  125.         kopi2[kounter]=input[kounter];
  126.     }
  127.     for(kounter=0; input[kounter]!='\0'; kounter++)
  128.     {
  129.         if(input[kounter]=='a' || input[kounter]=='i' || input[kounter]=='u' ||
  130.                 input[kounter]=='e' || input[kounter]=='o' || input[kounter]=='A' ||
  131.                 input[kounter]=='I' || input[kounter]=='U' || input[kounter]=='E' || input[kounter]=='O')
  132.         {
  133.             vokal++;
  134.             kopi[kounter]=' ';//Menghilang Huruf Vokal;
  135.         }
  136.         else if(input[kounter]==' ')
  137.         {
  138.             gang++;
  139.         }
  140.         else
  141.         {
  142.             konsonan++;
  143.             kopi2[kounter]=' ';//Menghilangkan Huruf Bukan Vokal
  144.         }
  145.     }
  146.     cout<<endl;
  147.     cout<<"Vocals           = "<<vokal<<endl;
  148.     cout<<"Consonant        = "<<konsonan<<endl;
  149.     cout<<"Spaces           = "<<gang<<endl;
  150.     cout<<endl;
  151.     cout<<"Hide Vocals      = "<<kopi<<endl;
  152.     cout<<"Hide Consonan    = "<<kopi2<<endl<<endl;
  153.     gang=1;
  154.     cout<<"Word #1          = ";
  155.     for(kounter=0; kounter<angka; kounter++)
  156.     {
  157.         if(input[kounter]==' ')
  158.         {
  159.             gang++;
  160.             cout<<endl;
  161.     cout<<"Word #"<<gang<<"          = ";
  162.         }
  163.         else
  164.         {
  165.             cout<<input[kounter];
  166.         }
  167.     }
  168.     cout<<endl<<endl;
  169.     cout<<"Input Offset     = ";
  170.     cin>>offset;
  171.     for(kounter=0; kounter<angka; kounter++)
  172.     {
  173.         kopi[kounter]=input[kounter];
  174.     }
  175.     for(kounter=0; input[kounter]!='\0'; kounter++)
  176.     {
  177.         if(input[kounter]==' ')
  178.         {
  179.             input[kounter]=' ';
  180.         }
  181.         else
  182.         {
  183.             gantine=int(kopi[kounter])+offset;//Merubah ke kode ASCII
  184.             if(input[kounter]>='a' && input[kounter]<='z'){
  185.                 if(gantine>122){
  186.                 gantine=gantine-26;
  187.             }
  188.                 else if(gantine<97){
  189.                     gantine=gantine+26;
  190.                 }
  191.             }
  192.             else if(input[kounter]>='A' && input[kounter]<='Z'){
  193.             if(gantine>90)
  194.             {
  195.                 gantine=gantine-26;
  196.             }
  197.             else if(gantine<65)
  198.             {
  199.                 gantine=gantine+26;
  200.             }
  201.         }
  202.             input[kounter]=char (gantine);//Merubah ASCII ke Karakter
  203.         }
  204.     }
  205.     cout<<"Offset Text      = "<<input;
  206.     cout<<endl;
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement