Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <ctime>
- #include <cstdlib>
- #include <string.h>
- using namespace std;
- int main()
- {/*
- qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890
- 01234567890123456789012345678901234567890123456789012345678901
- */
- string alfabeto = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
- string codice = "EhxkxYdq397oo0";
- string chiave = "rosarosarosaro";
- string finale = "";
- //cout << "Inserisci chiave :";
- //cin >> chiave;
- //cout << "Inserisci codice :";
- //cin >> codice;
- for (int i = 0;i!=codice.size();i++){
- char lettera;
- bool carattereSpeciale = true;
- for(int a = 0; a != alfabeto.length();a++){
- if (codice[i] == alfabeto[a]){
- carattereSpeciale = false;
- break;
- }
- }
- if (carattereSpeciale) {
- lettera = ' ';
- cout << "#" << endl;
- } else {
- int posCodice;
- int posChiave;
- for(int a = 0; a != alfabeto.length();a++){
- if (alfabeto[a] == codice[i]){
- posCodice = a;
- break;
- }
- }
- for(int b = 0; b != alfabeto.length();b++){
- if (alfabeto[b] == chiave[i]){
- posChiave = b;
- break;
- }
- }
- int posAlfa = posCodice - posChiave;
- lettera = alfabeto[posAlfa];
- //lettera = alfabeto[posAlfa-((posAlfa/alfabeto.length())*alfabeto.length())];
- cout << posCodice << " - " << posChiave << " = " << posAlfa << " / " << lettera << endl;
- }
- //finale.push_back(lettera);
- }
- //cout << finale << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement