Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Филипповых
- Group: СБС-901-О-01
- Task#: 5.32
- Description: дано n предложений. Вывести в алфвавитном порядке все встречающиеся в них слова.
- Каждое слово выводить по одному разу.
- */
- #include <cstdio>
- #include <clocale>
- #include <cstdlib>
- #include <ctime>
- #include <locale>
- #include<iomanip>
- #include <string.h>
- void result(int d,int str_length,char* alf_words[])
- {
- d += 1;
- printf("%d предложение\n", d);
- for (int i = 0; i < str_length; i++)
- {
- printf("%d\n", *alf_words[i]);
- }
- }
- void sort(int str_length, char* alf_words[])
- {
- for (int i = 0; i < str_length; i++)
- {
- for (int j = 0; j < str_length; j++)
- {
- if (strcmp(alf_words[j], alf_words[j + 1]) > 0)
- {
- char* Temp = alf_words[j];
- alf_words[j] = alf_words[j + 1];
- alf_words[j + 1] = Temp;
- }
- }
- }
- }
- const char alphabet[52] = { 'A','a','B','b','C','c','D','d','E','e','F','f','G','g','H','h','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','Q','q','R','r','S','s','T','t','U','u','V','v','W','w','X','x','Y','y','Z','z' };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- printf("сколько будет символов");
- int str_size;
- scanf_s("%d", &str_size);
- getchar();
- while (str_size < 0)
- {
- printf("нельзя вводить отрицательные числа\n");
- printf("сколько будет предложений?\n");
- scanf_s("%d", &str_size);
- getchar();
- }
- char* string = new char[str_size];
- printf("введите текст каждое предложение заканчиваете точкой.");
- scanf_s("%[^\n]s", string, str_size);
- getchar();
- const int str_length = strlen(string);
- char* alf_words[100][100];
- int metter_word = 0;
- int k = 0;
- char Temp;
- int d = 0;
- for (int i = 0; i < str_length; i++)
- {
- for (int j = 0; j < str_length; j++)
- {
- k = k + 1;
- if (string[k] != (' ' or ',' or '!' or '?' or '.'))
- {
- char* fferum = &string[k];
- alf_words[i][j] = fferum;
- }
- else
- {
- i = i + 1;
- j = 0;
- metter_word += 1;
- }
- if (string[k] == ('.'))
- {
- sort(str_length, alf_words[str_length]);
- /*
- for (int i = 0; i < str_length; i++)
- {
- for (int j = 0; j < str_length; j++)
- {
- if (strcmp(alf_words[j], alf_words[j + 1]) > 0)
- {
- Temp = *alf_words[j];
- *alf_words[j] = *alf_words[j + 1];
- *alf_words[j + 1] = Temp;
- }
- }
- }
- */
- result(d, str_length, alf_words[str_length]);
- /*d += 1;
- printf("%d предложение", d);
- for (int i = 0; i < str_length; i++)
- {
- printf("%s\n", *alf_words);
- }
- */
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement