Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- char str[50];
- cin.getline(str, 50);
- int n = strlen(str);
- bool p = false;
- for (int i = 0; i < n; i++)
- {
- if ((i == 0) || (str[i] != ' ' && str[i - 1] == ' '))
- {
- p = false;
- for (int j = i; str[j] != ' '; j++)
- {
- if (str[j] == 'w')
- {
- p = true;
- break;
- }
- }
- if (p == true)
- {
- for (int j = i; str[j] != ' '; j++)
- {
- cout << str[j];
- if (j == n - 1)
- {
- break;
- }
- }
- cout << endl;
- }
- }
- }
- int count = 3;
- cout << endl;
- bool f = false;
- if (str[n - count-1] == ' ')
- {
- for (int j = n - 1; j != n - count; j--)
- {
- if (str[j] == ' ')
- {
- f = true;
- }
- }
- }
- else
- {
- f = true;
- cout << "last slovo ne iz 3 bukv";
- }
- int count1 = 0;
- bool g = false;
- cout << endl;
- if (f == false)
- {
- for (int i = n - 1; i >= (n - count); i--)
- {
- cout << str[i];
- }
- }
- else if (f == true)
- {
- for (int i = 0; i < n; i++)
- {
- if (str[i] != ' ' && str[i - 1] == ' ')
- {
- count1++;
- }
- if (count1 == 3)
- {
- g = true;
- for (int j = i; str[j] != ' '; j++)
- {
- cout << str[j];
- if (j == n - 1)
- {
- break;
- }
- }
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment