BestTitan

VGLock

Jun 26th, 2024
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.83 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. char palabra[100];
  4. char clave[100];
  5. int numeros1[100];
  6. int numeros2[100];
  7. int main(){
  8.    
  9.    
  10.     // Una herramienta hecha por Best Titan
  11.     //Sitio Oficial: bt4games.blogspot.com
  12.    
  13.    
  14.     std::cin.tie(nullptr);
  15.     std::ios_base::sync_with_stdio(false);
  16.  
  17.     cout << endl << endl;
  18.  
  19.     cout << ":::     :::    ::::::::    :::         ::::::::    ::::::::   :::    :::" << endl;
  20.     cout << ":+:     :+:   :+:    :+:   :+:        :+:    :+:  :+:    :+:  :+:   :+: " << endl;
  21.     cout << "+:+     +:+   +:+          +:+        +:+    +:+  +:+         +:+  +:+  " << endl;
  22.     cout << "+#+     +:+   :#:          +#+        +#+    +:+  +#+         +#++:++  "  << endl;
  23.     cout << " +#+   +#+    +#+   +#+#   +#+        +#+    +#+  +#+         +#+  +#+  " << endl;
  24.     cout << "  #+#+#+#     #+#    #+#   #+#        #+#    #+#  #+#    #+#  #+#   #+# " << endl;
  25.     cout << "    ###        ########    ##########  ########    ########   ###    ###" << endl;
  26.  
  27.     cout << endl << endl;
  28.  
  29.     cout << "         [Escribe 1 para cifrar]         [Escribe 2 para descifrar]" << endl;
  30.  
  31.     int m = 0;
  32.     cin >> m;
  33.     cout << endl << "Escribe el texto a " << (m == 1 ? "cifrar " : "descifrar ") << "usando solo MAYUSCULAS (sin espacios)" << endl;
  34.     cin >> palabra;
  35.     cout << endl << "Escribe la contrasena para " << (m == 1 ? "cifrar " : "descifrar ") << " el texto usando solo MAYUSCULAS (sin espacios)" << endl;
  36.     cin >> clave;
  37.     cout << endl << "El texto " << (m == 1 ? "cifrado " : "descifrado ") << "es:" << endl;
  38.     int x = 0;
  39.     int y = 0;
  40.     int aux = 0;
  41.     for(int i = 0; i<100; i++){
  42.             numeros1[i] = palabra[i]-64;
  43.             numeros2[i] = clave[i]-64;
  44.             if(numeros2[i] == -64 && y == 0) y = i;
  45.             if(numeros2[i] == -64){
  46.                 if(aux == y) aux = 0;
  47.                 numeros2[i] = clave[aux]-64;
  48.                 aux++;
  49.             }
  50.  
  51.  
  52.             if(numeros1[i] == -64){
  53.                 x = i;
  54.                 break;
  55.                }
  56.  
  57.     }
  58.     if(m == 1){
  59.         int suma = 0;
  60.         char caracter = 0;
  61.         for(int i = 0; i<x; i++){
  62.             suma = numeros1[i] + numeros2[i] -1;
  63.             if(suma > 26) suma -= 26;
  64.             caracter = suma+64;
  65.             cout << caracter;
  66.         }
  67.     }
  68.     if(m == 2){
  69.         int suma = 0;
  70.         char caracter = 0;
  71.         for(int i = 0; i<x; i++){
  72.             suma = numeros1[i] - numeros2[i] +1;
  73.         if(suma<=0) suma += 26;
  74.         caracter = abs(suma)+64;
  75.  
  76.         cout << caracter;
  77.         }
  78.         }
  79.     cout << endl << endl << endl << "Para cifrar o descifrar otro texto cierra y vuelve a abrir el programa";
  80.     cout << endl << endl << "Una herramienta hecha por Best Titan" << endl << "Sitio Oficial: bt4games.blogspot.com"<< endl;
  81.     cin >> m;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment