Bagosep

pengganti_huruf

Nov 28th, 2016
160
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char ganti1,ganti2,kata[50];
  8.     int kounter;
  9.  
  10.     cout<<"Masukan Kalimat Awal \t\t: ";cin.getline(kata, 50);
  11.  
  12.     cout<<"Masukan Huruf yang akan diganti\t: ";cin>>ganti1;
  13.     cout<<"Masukan Pengganti huruf\t\t: ";cin>>ganti2;
  14.  
  15.     for(kounter=0;kounter<strlen(kata);kounter++){
  16.         if(kata[kounter]==ganti1){
  17.             kata[kounter]=ganti2;
  18.         }
  19.     }
  20.     cout<<endl;
  21.     cout<<endl;
  22.     cout<<kata;
  23.     cout<<endl;
  24.  
  25.     return 0;
  26. }
RAW Paste Data