Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.02 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4.  
  5. int main(){
  6.     int len_text = 1;
  7.     int len_sen = 2;
  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.             len_text+=1;
  17.             text = realloc(text, sizeof(char*)*(len_text));
  18.             text[i][j] = c;
  19.             text[i+1] = (char*) calloc(2, sizeof(char));
  20.             i++;
  21.             j=0;
  22.             len_sen = 2;
  23.             continue;
  24.         } else {
  25.             text[i][j] = c;
  26.         }
  27.  
  28.         if(j >= len_sen-2){
  29.             len_sen+=2;
  30.             text[i] = realloc(text[i], (len_sen)*sizeof(char));
  31.         }
  32.         j++;
  33.     }while(c != '!');
  34.     int n = 0;
  35.     int k = 0;
  36.     int h = i;
  37.     for(int m = 0; m <= i; m++){
  38.         int num = 0;
  39.         char f = text[m][n];
  40.         while(f != '.' || f != ';' || f != '?'){
  41.             int q = (int)f;
  42.             if (q >= 65 && q <= 90)
  43.                 num += 1;
  44.             if (text[m][n] == '!') {
  45.                 break;
  46.             }
  47.             n++;
  48.             f = text[m][n];
  49.         }
  50.         n = 0;
  51.         if(num >= 2)
  52.             continue;
  53.         while(f != '.' || f != ';' || f != '?'){
  54.             if((text[m][n] == ' ' && text[m][n+1] == ' ') || (text[m][n] == '\t') || (text[m][0] == ' ' && n == 0) ){
  55.                 n++;
  56.                 continue;
  57.             }
  58.             printf("%c", text[m][n]);
  59.             n++;
  60.             if(f == '.' || f == ';' || f == '?')
  61.                 break;
  62.             if(text[m][n] == '!'){
  63.                 printf("%c", text[i][j-1]);
  64.                 break;
  65.             }
  66.             f = text[m][n];
  67.         }
  68.         n = 0;
  69.         printf("\n");
  70.         k++;
  71.     }
  72.     if(k<=0)
  73.         k = 1;
  74.     printf("Количество предложений до %d и количество предложений после %d", h, (k-1));
  75.     free(text);
  76.     return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement