Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(){
- int len_text = 1;
- int len_sen = 2;
- int i=0;
- int j=0;
- char c;
- char** text = calloc(len_text, sizeof(char*));
- text[i] = (char*) calloc(len_sen, sizeof(char));
- do{
- c = getchar();
- if(c == '.' || c == '?' || c == ';'){
- len_text+=1;
- text = realloc(text, sizeof(char*)*(len_text));
- text[i][j] = c;
- text[i+1] = (char*) calloc(2, sizeof(char));
- i++;
- j=0;
- len_sen = 2;
- continue;
- } else {
- text[i][j] = c;
- }
- if(j >= len_sen-2){
- len_sen+=2;
- text[i] = realloc(text[i], (len_sen)*sizeof(char));
- }
- j++;
- }while(c != '!');
- int n = 0;
- int k = 0;
- int h = i;
- for(int m = 0; m <= i; m++){
- int num = 0;
- char f = text[m][n];
- while(f != '.' || f != ';' || f != '?'){
- int q = (int)f;
- if (q >= 65 && q <= 90)
- num += 1;
- if (text[m][n] == '!') {
- break;
- }
- n++;
- f = text[m][n];
- }
- n = 0;
- if(num >= 2)
- continue;
- while(f != '.' || f != ';' || f != '?'){
- if((text[m][n] == ' ' && text[m][n+1] == ' ') || (text[m][n] == '\t') || (text[m][0] == ' ' && n == 0) ){
- n++;
- continue;
- }
- printf("%c", text[m][n]);
- n++;
- if(f == '.' || f == ';' || f == '?')
- break;
- if(text[m][n] == '!'){
- printf("%c", text[i][j-1]);
- break;
- }
- f = text[m][n];
- }
- n = 0;
- printf("\n");
- k++;
- }
- if(k<=0)
- k = 1;
- printf("Количество предложений до %d и количество предложений после %d", h, (k-1));
- free(text);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement