Advertisement
fferum

Untitled

May 23rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.57 KB | None | 0 0
  1. /*
  2.     Author: Филипповых
  3.  
  4.     Group: СБС-901-О-01
  5.  
  6.     Task#: 5.32
  7.  
  8.     Description: дано n предложений. Вывести в алфвавитном порядке все встречающиеся в них слова.
  9.     Каждое слово выводить по одному разу.
  10.  
  11. */
  12. #include <cstdio>
  13. #include <clocale>
  14. #include <cstdlib>
  15. #include <ctime>
  16. #include <locale>
  17. #include<iomanip>
  18. #include <string.h>
  19. void result(int d,int str_length,char* alf_words[])
  20. {
  21.     d += 1;
  22.     printf("%d предложение\n", d);
  23.     for (int i = 0; i < str_length; i++)
  24.     {
  25.         printf("%d\n", *alf_words[i]);
  26.     }
  27. }
  28. void sort(int str_length, char* alf_words[])
  29. {
  30.     for (int i = 0; i < str_length; i++)
  31.     {
  32.         for (int j = 0; j < str_length; j++)
  33.         {
  34.             if (strcmp(alf_words[j], alf_words[j + 1]) > 0)
  35.             {
  36.                 char* Temp = alf_words[j];
  37.                 alf_words[j] = alf_words[j + 1];
  38.                 alf_words[j + 1] = Temp;
  39.             }
  40.         }
  41.     }
  42. }
  43. 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' };
  44. int main()
  45. {
  46.     setlocale(LC_ALL, "Russian");
  47.     printf("сколько будет символов");
  48.     int str_size;
  49.     scanf_s("%d", &str_size);
  50.     getchar();
  51.     while (str_size < 0)
  52.     {
  53.         printf("нельзя вводить отрицательные числа\n");
  54.         printf("сколько будет предложений?\n");
  55.         scanf_s("%d", &str_size);
  56.         getchar();
  57.     }
  58.     char* string = new char[str_size];
  59.     printf("введите текст каждое предложение заканчиваете точкой.");
  60.     scanf_s("%[^\n]s", string, str_size);
  61.     getchar();
  62.     const int str_length = strlen(string);
  63.     char* alf_words[100][100];
  64.     int metter_word = 0;
  65.     int k = 0;
  66.     char Temp;
  67.     int d = 0;
  68.     for (int i = 0; i < str_length; i++)
  69.     {
  70.         for (int j = 0; j < str_length; j++)
  71.  
  72.         {
  73.            
  74.             k = k + 1;
  75.             if (string[k] != (' ' or ',' or '!' or '?' or '.'))
  76.             {
  77.                 char* fferum = &string[k];
  78.                 alf_words[i][j] = fferum;
  79.  
  80.             }
  81.             else
  82.             {
  83.                 i = i + 1;
  84.                 j = 0;
  85.                 metter_word += 1;
  86.             }
  87.             if (string[k] == ('.'))
  88.             {
  89.                 sort(str_length, alf_words[str_length]);
  90.                 /*
  91.                     for (int i = 0; i < str_length; i++)
  92.                     {
  93.                         for (int j = 0; j < str_length; j++)
  94.                         {
  95.                             if (strcmp(alf_words[j], alf_words[j + 1]) > 0)
  96.                             {
  97.                                 Temp = *alf_words[j];
  98.                                 *alf_words[j] = *alf_words[j + 1];
  99.                                 *alf_words[j + 1] = Temp;
  100.                             }
  101.                         }
  102.                     }
  103.                    */
  104.                    
  105.                 result(d, str_length, alf_words[str_length]);
  106.                 /*d += 1;
  107.                     printf("%d предложение", d);
  108.                 for (int i = 0; i < str_length; i++)
  109.                 {
  110.                     printf("%s\n", *alf_words);
  111.                 }
  112.                 */
  113.             }
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement