Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <fstream>
- using namespace std;
- int main(int argc, char **args)
- {
- ifstream inputFile(args[1]);
- if (!inputFile)
- {
- cout << "Blad odczytu pliku!";
- return 0;
- }
- else
- {
- ofstream outputFile (args[2], ios_base::in | ios_base::app);
- if (!outputFile)
- {
- cout << "Blad pliku wyjsciowego!";
- return 0;
- }
- else
- {
- char cipher[5][5];
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- cipher[i][j] = 65 + i*5 + j;
- }
- }
- cipher[1][4] = 'K';
- for (int i = 2; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- cipher[i][j] = 66 + i*5 + j;
- }
- }
- if (strcasecmp(args[3], "1") == 0)
- {
- // szyfrowanie
- string input;
- inputFile >> input;
- for (int i = 0; i < input.length(); i++)
- {
- if (input[i] == 'J')
- {
- outputFile << "24 ";
- }
- else
- {
- for (int j = 0; j < 5; j++)
- {
- for (int k = 0; k < 5; k++)
- {
- if (input[i] == cipher[j][k])
- {
- outputFile << i+1 << j+1 << " ";
- }
- }
- }
- }
- }
- }
- else if (strcasecmp(args[3], "0") == 0)
- {
- // deszyfrowanie
- }
- else
- {
- cout << "Blad argumentu trybu pracy!";
- return 0;
- }
- }
- outputFile.close();
- }
- inputFile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement