Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int gr, i, cnt = 0;
- char textn [256], sm;
- bool lst = false, fst = false;
- char * sd;
- int main ()
- {
- cout << "Enter text : ";
- gets(textn);
- cout << endl;
- cout << "New text : ";
- for (int i = 0; i <strlen (textn); i ++)
- {
- if (strlen (textn) - 1> i && i> 0)
- cout << textn [i];
- if (i == 0 || i == strlen (textn) - 1)
- cout << "-";
- }
- cout << endl;
- // 2
- cout << "Enter text : ";
- gets(textn);
- sd = strtok (textn, "-;:,.! / @ &");
- while (sd != NULL)
- {
- cnt ++;
- sd = strtok (NULL, "-;:,.! / @ &");
- }
- cout << '\n'
- << "Words = " << cnt << endl;
- cout << endl;
- cnt = 0;
- // 3
- cout << "Enter text : ";
- gets(textn);
- for (i = 0; textn [i] != '\0'; i ++)
- {
- while (textn [i] != ' ' && textn [i] != '\0')
- {
- if (fst == false)
- {
- sm = textn [i];
- }
- i ++;
- fst = true;
- }
- if (textn [i] == ' ' || textn [i] == '\0')
- {
- lst = true;
- }
- if (lst == true)
- {
- if (textn [i - 1] == sm)
- {
- cnt ++;
- }
- }
- lst = false;
- fst = false;
- }
- cout << "Words = " << cnt << endl;
- cout << endl;
- cnt = 0;
- //4
- cout << "Enter text : ";
- gets(textn);
- cout << "Symbol : ";
- cin >> sm;
- for (i = 0; textn[i] != '\0'; i++)
- {
- while (textn[i] != ' ' && textn[i] != '\0')
- {
- i++;
- }
- if (textn[i] == ' ' || textn[i] == '\0')
- {
- lst = true;
- }
- if (lst == true)
- {
- if (textn[i - 1] == sm)
- {
- cnt++;
- }
- }
- lst = false;
- }
- cout << "Words =" << cnt << endl;
- cin.ignore();
- cout << endl;
- //5
- cout << "Enter text : ";
- gets(textn);
- cout << "Symbol : ";
- cin >> sm;
- for (i = 0; textn[i] != '\0'; i++)
- {
- while (textn[i] != ' ' && textn[i] != '\0')
- {
- if (textn[i] == sm)
- {
- gr = i;
- while (textn[gr] != '\0')
- {
- textn[gr] = textn[gr + 1];
- gr++;
- }
- }
- if (textn[i] != sm)
- i++;
- }
- }
- cout << "Text after removing = " << textn << endl;
- cout << endl;
- delete [] sd;
- cin.get();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement