Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void myCript(int m1, int l1, char* arr);
- int main()
- {
- char str[101];
- int M, L;
- int i = 0, counter = 0;
- bool flag = true;
- cin.getline(str, 101);
- while (true)
- {
- cout << "Enter M" << endl;
- cin >> M;
- if (cin.fail())
- {
- cout << "Error! Try again";
- cin.clear();
- cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
- cin >> M;
- }
- else if (M > 20)
- {
- cout << "Error! Try again";
- cin.clear();
- cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
- cin >> M;
- }
- else
- {
- break;
- }
- }
- while (true)
- {
- cout << "Enter L" << endl;
- cin >> L;
- if (cin.fail())
- {
- cout << "Error! Try again";
- cin.clear();
- cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
- cin >> L;
- }
- else if (L > 100)
- {
- cout << "Error! Try again";
- cin.clear();
- cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
- cin >> L;
- }
- else
- {
- break;
- }
- }
- while (str[i] != '\0')
- {
- i++;
- }
- for (int j = 0; j < i; j++)
- {
- if (str[j] < 32 || str[j] > 126)
- {
- flag = false;
- }
- }
- if (!flag)
- {
- cout << "invalid symbols" << endl;
- }
- cout << str;
- system("pause");
- return 0;
- }
- void myCript(int m, int l, char* arr)
- {
- int counter = 0;
- while (arr[counter] != '\0')
- {
- counter ++ ;
- }
- for (int i = 0; i < counter; i++)
- {
- if (i + l > counter )
- {
- arr[i] = arr[abs(counter - i - l)];
- }
- else
- {
- arr[i + l] = arr[i];
- }
- }
- for (int j = 0; j < counter; j++)
- {
- arr[j] = arr[j] + m;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement