Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- using namespace std;
- string ifAuthor(const string& temp, int& index , const int &iStr)
- {
- string author = "";
- // проверка наличия одного(!) пробела
- unsigned int nOfSymbols = 0;
- for (unsigned int j = 0; temp[j] != '|'; ++j)
- {
- if (temp[j] == ' ')
- ++nOfSymbols;
- if (nOfSymbols > 1)
- {
- throw iStr;
- }
- }
- if (nOfSymbols != 1)
- {
- throw iStr;
- }
- // проверка фамилии и инициалов
- if (temp[index] >= 'А' && temp[index] <= 'Я' || temp[index] == 'Ё')
- {
- author += temp[index];
- ++index;
- for (; temp[index] != ' '; ++index)
- {
- if (temp[index] >= 'а' && temp[index] <= 'я' || temp[index] == 'ё')
- author += temp[index];
- else
- {
- throw iStr;
- }
- }
- author += ' ';
- ++index;
- if (temp[index + 4] != '|')
- {
- throw iStr;
- }
- if ((temp[index] >= 'А' && temp[index] <= 'Я' || temp[index] == 'Ё') &&
- temp[index + 1] == '.' &&
- (temp[index + 2] >= 'А' && temp[index + 2] <= 'Я' || temp[index + 2] == 'Ё') &&
- temp[index + 3] == '.')
- {
- for (; temp[index] != '|'; index++)
- author += temp[index];
- }
- else
- {
- throw iStr;
- }
- }
- else
- {
- throw iStr;
- }
- ++index;
- return author;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement