Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void add (char* a, char* b);
- bool check(char* m);
- void clean(char* m);
- bool compare (char* a, char* b);
- void padezh(int count);
- bool find (char* a, char* b, int &pos);
- const int NUM_DIFF_WORD = 10000+1, WORD_LENGTH = 80+1;
- int main()
- {
- locale::global(locale("rus"));
- char m[NUM_DIFF_WORD][WORD_LENGTH], temp[WORD_LENGTH];
- int mc[NUM_DIFF_WORD]; for (int i = 0; i < NUM_DIFF_WORD; i++) *(mc+i) = 0;
- int pos = 0, w_count = 0;
- cin >> temp;
- while (check(temp))
- {
- if (find(m[0], temp, pos))
- mc[pos]++;
- else
- {
- w_count++;
- add(m[w_count], temp);
- mc[w_count]++;
- }
- cin >> temp;
- }
- cout << "\nСтатистика:\n\n";
- for (int j = 1; j <= w_count; j++)
- {
- cout << m[j] << ". Употреблено "<< mc[j]; padezh(mc[j]);
- }
- system("pause");
- return 0;
- }
- bool check(char* m)
- {
- int i;
- for (i = 0; *(m + i); i++);
- i--;
- if (*(m + i) == '.')
- {
- *(m + i) = '\0';
- return false;
- }
- else return true;
- }
- void clean(char* m)
- {
- for(int i = 0; *(m + i); i++) *(m + i) = NULL;
- }
- bool compare (char* a, char* b)
- {
- int i;
- for(i = 0; *(a+i) && *(b+i); i++)
- if (*(a+i) != *(b+i)) return false;
- if (*(a+i) != *(b+i)) return false;
- else return true;
- }
- void padezh(int count)
- {
- if ((count % 10 == 2 || count % 10 == 3 || count % 10 == 4) && (count / 10 != 1)) cout << " раза.\n";
- else cout << " раз.\n";
- }
- bool find (char* a, char* b, int &pos)
- {
- for(int i = 0; *(a+WORD_LENGTH*i); i++)
- {
- if (compare((a + WORD_LENGTH * i), b))
- {
- pos = i;
- return true;
- }
- }
- return false;
- }
- void add (char *a, char* b)
- {
- int i;
- for (i = 0; *(b+i); i++)
- {
- *(a+i) = *(b+i);
- }
- *(a+i) = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment