Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- char c, text[256], s[256][256];
- cin >> c;
- getchar();
- gets(text);
- int n = strlen(text);
- int k = 0;
- for (int i = 0, j = 0; i <= n; i++)
- {
- if (text[i] == ' ' || !text[i])
- {
- if (!i || text[i - 1] != ' ')
- {
- strncpy(s[k], text + i - j, j);
- s[k][j] = 0;
- k++;
- j = 0;
- }
- }
- else
- j++;
- }
- cout << "cuvinte ce contin '" << c << "' : ";
- int nr = 0;
- for (int i = 0; i < k; i++)
- if (strchr(s[i], c))
- {
- nr++;
- cout << s[i] << ' ';
- }
- cout << endl << "nr: " << nr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement