Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mm_malloc.h>
- //#include <stdio.h>
- //#include <string.h>
- #include <cstdio>
- #include <cstring>
- //#include <stdlib.h>
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int sr(char *b, char **c, int j) {
- int i=0, k = 0, h=0, i1;
- j=0;
- while (b[i] != 0) {
- while (b[i] == ' ') {
- i++;
- }
- if (b[i] == 0) {
- return j;
- }
- c = (char**)realloc(c, (j + 1)*sizeof(char*));
- i1=i;
- while (b[i1] != '.' && b[i1] != ',' && b[i1] != ' ' && b[i1] !=0){
- h++;
- i1++;
- }
- c[j] = (char*)calloc((size_t) h+1, sizeof(char));
- for (k=0; k<h; k++, i++){
- c[j][k] = b[i];
- }
- j++;
- char *p1;
- char p = '.';
- p1 = strchr(&b[i+1], p);
- i = *p1 + 1;
- h = 0;
- }
- return j;
- }
- int main() {
- int i, j, N;
- size_t l = 0;
- char **a = 0;
- char *b = 0;
- char **c=0;
- scanf("%d", &N);
- N++;
- a = (char**)calloc(N, sizeof(char*));
- for (i = 0; i < N; i++) {
- a[i] = (char*)calloc(81, sizeof(char));
- }
- for (i = 0; i < N; i++) {
- cin.getline(a[i], 80);
- }
- for (i = 0; i < N; i++) {
- l = l + strlen(a[i]) + 1;
- b = (char*)realloc(b, (l)*sizeof(char));
- strcat(b, a[i]);
- strcat(b, " ");
- }
- i=0;
- while (b[i]==' ') {
- i++;
- }
- b[i-1]='.';
- sr(b, c, j);
- printf("%d",j);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement