#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
bool checkRuss(const std::string &str)
{
return (str.find_first_not_of("абвгдеёжзиклмнопрстуфхцчьыъэюяАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧЬЫЪЭЮЯ") == std::string::npos);
}
bool checkRussAndLat(const std::string &str)
{
return (str.find_first_of("абвгдеёжзиклмнопрстуфхцчьыъэюяАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧЬЫЪЭЮЯ") != std::string::npos)
&& (str.find_first_of("abdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos);
}
bool checkNumbersAndOther(const std::string &str)
{
for (int i = 0; i < str.length(); i++)
if (str[i] < 'a')
return true;
return false;
}
void printVector(const std::vector<std::string> &v)
{
for (int i = 0; i < v.size(); i++)
std::cout << "\t" << v[i] << std::endl;
}
int main(int argc, char *argv[])
{
std::vector<std::string> strings;
strings.push_back("Разраз");
strings.push_back("Test Test");
strings.push_back("123456");
strings.push_back("1234Test");
strings.push_back("Раз два Test");
std::cout << "Input array:" << std::endl;
printVector(strings);
std::vector<std::string> onlyRuss, russAndLat, numbersAndOther;
for (int i = 0; i < strings.size(); i++)
{
std::string &str = strings[i];
bool hasRuss = checkRuss(str);
bool hasLat = checkRussAndLat(str);
bool hasNums = checkNumbersAndOther(str);
if (hasRuss && !hasLat && !hasNums)
onlyRuss.push_back(str);
if (hasRuss && hasLat)
russAndLat.push_back(str);
if (hasNums)
numbersAndOther.push_back(str);
}
std::cout << "Only russian array: " << std::endl;
printVector(onlyRuss);
std::cout << "Russian and Latin array: " << std::endl;
printVector(russAndLat);
std::cout << "Numbers and other array: " << std::endl;
printVector(numbersAndOther);
system("PAUSE");
return 0;
}