Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdlib.h"
- #include <iostream>
- using namespace std;
- int main(void)
- {
- string sentence, alphabet, newAlphabet, rest, crypt;
- int shift = 0, choice = 0;
- alphabet = "abcdefghijklmnopqrstuvwxyz";
- cout << "Voulez-vous chiffrer (1) ou d\202chiffrer (2) : ";
- cin >> choice;
- if (choice == 1)
- {
- cout << "Entrez la phrase \205 chiffrer : ";
- cin >> sentence;
- cout << "Entrez le chiffre de C\202sar : ";
- cin >> shift;
- newAlphabet = alphabet.substr(shift);
- rest = alphabet.substr(0, shift);
- newAlphabet += rest;
- for(int i = 0; i < sentence.length(); ++i)
- {
- size_t pos = alphabet.find(sentence.at(i));
- crypt += newAlphabet.at(pos);
- }
- }
- else if (choice == 2)
- {
- cout << "Entrez la phrase \205 d\202chiffrer : ";
- cin >> sentence;
- cout << "Entrez le chiffre de C\202sar : ";
- cin >> shift;
- newAlphabet = alphabet.substr(shift);
- rest = alphabet.substr(0, shift);
- newAlphabet += rest;
- for(int i = 0; i < sentence.length(); ++i)
- {
- size_t pos = newAlphabet.find(sentence.at(i));
- crypt += alphabet.at(pos);
- }
- }
- else
- {
- cout << "Vous n'avez pas rentr\202 1 ou 2." << endl;
- return 0;
- }
- cout << crypt << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement