Szyfr kolumnowy

Janek · November 04, 2024
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string jawny, szyfrogram = ""; // Poprawna deklaracja zmiennych typu string
    int klucz, dl;

    cout << "Podaj tekst jawny (bez spacji): ";
    cin >> jawny;
    cout << "Podaj klucz szyfrowania: ";
    cin >> klucz;

    dl = jawny.length(); // Zmieniono "długość" na "length" - właściwa nazwa metody w C++

    for (int i = 0; i < klucz; i++) {
        for (int j = i; j < dl; j = j + klucz) {
            szyfrogram = szyfrogram + jawny[j];
        }
    }

    cout << "\nSzyfrogram: " << szyfrogram << endl; // Zmieniono "Szyfrogram" na "szyfrogram" (wielkość liter)
    return 0; // Zmieniono "zwróć" na "return" - poprawne słowo kluczowe w C++
}
Output

Comments

Please sign up or log in to contribute to the discussion.