Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include<cctype>
- #include<time.h>
- #define _CRT_SECURE_NO_WARNINGS
- #pragma warning(disable: 4996)
- using namespace std;
- int main() {
- srand(time(0));
- int a = 20;
- FILE* fp;
- fp = fopen("test.txt", "w+");
- fprintf(fp, "This is line 1\n");
- fclose(fp);
- FILE* fp1;
- fp1 = fopen("test1.txt", "w+");
- fclose(fp1);
- fstream test;
- test.open("test.txt", ios::in);
- if (test.is_open()) {
- string text;
- string code;
- while (getline(test, text))
- {
- int *numbers = new int[text.length()];
- for (int i = 0; i < text.length(); i++)
- {
- if (isblank(text[i]) != 0)
- {
- cout << text[i];
- code += " ";
- }
- else
- {
- int x = (rand() % 30);
- numbers[i] = x;
- char t = text[i] + x;
- cout << t;
- code += t;
- }
- }
- cout << endl;
- fstream test1;
- test1.open("test1.txt", ios::out);
- if (test1.is_open())
- {
- test1 << code;
- test1.close();
- }
- test1.open("test1.txt", ios::in);
- if (test1.is_open()) {
- string text1;
- while (getline(test1, text1)) {
- for (int i = 0; i < text1.length(); i++)
- {
- char t1 = text1[i] - numbers[i];
- if (t1 == 'S')
- cout << " ";
- else
- cout << t1;
- }
- }
- test1.close();
- }
- }
- test.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement