Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.28 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int main(){
  6.     int len_text = 1;
  7.     int len_sen = 1;
  8.     int i=0; // количество предложений
  9.     int j=0; //количество символов в предложении
  10.     char c;
  11.     char** text = calloc(len_text, sizeof(char*));
  12.     text[i] = (char*) calloc(len_sen, sizeof(char));
  13.     do{
  14.         c = getchar();
  15.         if(c == '.' || c == '?' || c == ';'){
  16.             text = realloc(text, sizeof(char*)*(len_text++));
  17.             text[i][j] = c;
  18.             text[i+1] = (char*) calloc(1, sizeof(char));
  19.             i++;
  20.             j=0;
  21.             len_sen = 1;
  22.         } else {
  23.             text[i][j] = c;
  24.         }
  25.  
  26.         if(j >= len_sen){
  27.             text[i] = realloc(text[i], (len_sen+=1)*sizeof(char));
  28.         }
  29.         j++;
  30.     }while(c != '!');
  31.  
  32.     int n = 0;
  33.     char f = text[0][0]; //получаем первый символ первого предложения
  34.     for(int m = 0; m <= i; m++){
  35.  
  36.         while(f != '.' || f != ';' || f != '?'){
  37.             printf("%c", text[m][n]);
  38.             n++;
  39.             if(text[m][n] == text[i][j]){
  40.                 break;
  41.             }
  42.             f = text[m][n];
  43.         }
  44.         n = 0;
  45.  
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement