Jawaban #8 Algoritma Enkripsi

// -------------------------------------------------------
// Author : Asadullohil Ghalib - gadzata@gmail.com
// -------------------------------------------------------
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	string a[50] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", " "};
	string b[50] = {"z","y","x","w","v","u","t","s","r","q","p","o","n","m","l","k","j","i","h","g","f","e","d","c","b","a", " "};
	string huruf[1000], hslhuruf[1000];
	
	int jmlcase, jmlkalimat;
	string kalimat, hasil;
	cout << "Masukkan Jumlah TestCase : "; cin >> jmlcase ;
	getline(cin,kalimat);
	for (int i=1;i<=jmlcase;i++){
		cout << "Input : "; 
		hasil = "";
		getline (cin,kalimat);
		jmlkalimat = kalimat.size();
		for(int j=1;j<=jmlkalimat;j++){
			huruf[j] = kalimat.substr(j-1,1);
		}
		for(int k=1;k<=jmlkalimat;k++){
			if (huruf[k] == "("){
				do {
					hslhuruf[k] = huruf[k];
					k++;
				} while (huruf[k] != ")");
				hslhuruf[k] = ")";	
				
			}
			else{
				for (int s=0;s<=26;s++){ 
					if (huruf[k] == a[s]){
						hslhuruf[k] = b[s];	
					
					}
				}		
			}
						
		}
		
		for (int f=1;f<=jmlkalimat;f++){
			hasil += hslhuruf[f];
		}
		
		cout << "output : " << hasil << endl; 
		
	}

}

One thought on “Jawaban #8 Algoritma Enkripsi

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s