Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- string str;
- int el_vec = 0;
- int kol = 0;
- vector<char>str_dop;
- int w = 0;
- cout << "vvedite str: " << endl;
- getline(cin, str);
- int n;
- n = str.length();
- string str_glas;
- int l;
- cout << "vvedite str_glas: " << endl;
- getline(cin, str_glas);
- l = str_glas.length();
- int v = 0;
- for (int i = 0; i < n; i++){
- if (str[i] != '.')v++;
- if (str[i] == '.')break;
- }
- for (int i = 0; i < v; i++){
- for (int j = 0; j < l; j++){
- if(str[0] == str_glas[j]){w++; break;}
- }
- }
- if (w > 0){
- for (int i = 0; i < v; i++){
- if (str[i] != ' '){
- str_dop.push_back(str[i]);
- el_vec++;
- }
- if (str[i] == ' ')break;
- }
- str_dop.push_back(' ');
- el_vec++;
- }
- else cout << " 1 slovo nach ne s glas " << endl;
- w = 0;
- int k = 0;
- for (int i = 1; i < v; i++){
- k++;
- if ((str[i - 1] == ' ') && (str[i] != ' ')){
- for (int j = 0; j < l; j++){
- if (str[i] == str_glas[j])w++;
- }
- }
- if (w > 0){
- for (int j = k; j < v; j++){
- if (str[j] != ' '){
- str_dop.push_back(str[j]);
- el_vec++;
- }
- if (str[j] == ' '){
- str_dop.push_back(' ');
- el_vec++;
- break;}
- }
- w = 0;
- }
- if (w = 0)continue;
- }
- for (int i = 0; i < el_vec; i++){
- if (str_dop[i] == ' ')kol++;
- }
- cout << endl << "kol-vo slov nach s glas: " << kol + 1 << endl;
- cout << endl;
- cout << "slova nach s glas: ";
- for (int i = 0; i < el_vec; i++){
- cout << str_dop[i];
- }
- cout << endl;
- int b = 1;
- vector<char>str_dop2;
- int el_vec2 = 0;
- for (int i = 0; i < n; i++){
- if (str[i] == ' '){b++;
- if (b > 2){str_dop2.push_back(' ');
- el_vec2++;
- }
- }
- if (((b % 4) == 0) && (str[i] != ' ') && (str[i] != '.')){
- str_dop2.push_back(str[i]);
- el_vec2++;
- }
- }
- cout << endl;
- cout << "slova s kratnim 4 nomerom: ";
- for (int i = 0; i < el_vec2; i++){
- cout << str_dop2[i];
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement