Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void DoThat(char x[], char y[], int N,char z[])
- {
- int i, j;
- int words = 1;
- for (i = 0; x[i] != '\0'; i++)
- {
- if (x[i] == ' ')
- {
- words++;
- }
- if (words == N)
- {
- i++;
- break;
- }
- }
- for (j = 0;; j+=2)
- {
- if (x[i] == ' ')
- {
- break;
- }
- z[j] = x[i];
- i++;
- }
- z[j] = '\0';
- //
- words = 1;
- for (i = 0; y[i] != '\0'; i++)
- {
- if (y[i] == ' ')
- {
- words++;
- }
- if (words == N)
- {
- i++;
- break;
- }
- }
- for (j = 1;; j += 2)
- {
- if (y[i] == ' ')
- {
- break;
- }
- z[j] = y[i];
- i++;
- }
- z[j] = '\0';
- //
- }
- void main()
- {
- char x[100], y[100], z[100];
- int n = 3;
- gets_s(x);
- gets_s(y);
- DoThat(x, y, n, z);
- cout << z;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement