Всем привет! Как сделать так, чтобы в коде ниже можно было учитывать пробел? Вариант с cin.getline() тут не подходит. Можно ли вообще это реализовать?
#include<iostream>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
string str2= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
string str3= "1011121314151617181920212223242526272829303132333435";
string str1;
string res = "";
cout << "Enter word you want encrypt" << endl;
cin >> str1;
for (int i = 0; i < str1.length(); i++)
{
if (str1[i] == 'a'|| str1[i] == 'A') res += str2.replace(0, 52, str3, 0, 2); else
if (str1[i] == 'b'|| str1[i] == 'B') res += str2.replace(0, 52, str3, 2, 2); else
if (str1[i] == 'c'|| str1[i] == 'C') res += str2.replace(0, 52, str3, 4, 2); else
if (str1[i] == 'd'|| str1[i] == 'D') res += str2.replace(0, 52, str3, 6, 2); else
if (str1[i] == 'e'|| str1[i] == 'E') res += str2.replace(0, 52, str3, 8, 2); else
if (str1[i] == 'f'|| str1[i] == 'F') res += str2.replace(0, 52, str3, 10, 2); else
if (str1[i] == 'g'|| str1[i] == 'G') res += str2.replace(0, 52, str3, 12, 2); else
if (str1[i] == 'h'|| str1[i] == 'H') res += str2.replace(0, 52, str3, 14, 2); else
if (str1[i] == 'i'|| str1[i] == 'I') res += str2.replace(0, 52, str3, 16, 2); else
if (str1[i] == 'j'|| str1[i] == 'J') res += str2.replace(0, 52, str3, 18, 2); else
if (str1[i] == 'k'|| str1[i] == 'K') res += str2.replace(0, 52, str3, 20, 2); else
if (str1[i] == 'l'|| str1[i] == 'L') res += str2.replace(0, 52, str3, 22, 2); else
if (str1[i] == 'm'|| str1[i] == 'M') res += str2.replace(0, 52, str3, 24, 2); else
if (str1[i] == 'n'|| str1[i] == 'N') res += str2.replace(0, 52, str3, 26, 2); else
if (str1[i] == 'o'|| str1[i] == 'O') res += str2.replace(0, 52, str3, 28, 2); else
if (str1[i] == 'p'|| str1[i] == 'P') res += str2.replace(0, 52, str3, 30, 2); else
if (str1[i] == 'q'|| str1[i] == 'Q') res += str2.replace(0, 52, str3, 32, 2); else
if (str1[i] == 'r'|| str1[i] == 'R') res += str2.replace(0, 52, str3, 34, 2); else
if (str1[i] == 's'|| str1[i] == 'S') res += str2.replace(0, 52, str3, 36, 2); else
if (str1[i] == 't'|| str1[i] == 'T') res += str2.replace(0, 52, str3, 38, 2); else
if (str1[i] == 'u'|| str1[i] == 'U') res += str2.replace(0, 52, str3, 40, 2); else
if (str1[i] == 'v'|| str1[i] == 'V') res += str2.replace(0, 52, str3, 42, 2); else
if (str1[i] == 'w'|| str1[i] == 'W') res += str2.replace(0, 52, str3, 44, 2); else
if (str1[i] == 'x'|| str1[i] == 'X') res += str2.replace(0, 52, str3, 46, 2); else
if (str1[i] == 'y'|| str1[i] == 'Y') res += str2.replace(0, 52, str3, 48, 2); else
if (str1[i] == 'z'|| str1[i] == 'Z') res += str2.replace(0, 52, str3, 50, 2);
}
cout << res << endl;
system("pause");
return 0;
}