Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <iostream>
- using namespace std;
- void substr(char str[][81], int n, char str1[][81], int *n1, int num[])
- {
- int i;
- char *s, *chars="!,.:;?", *s1, *s2;
- *n1 = 0;
- for(i=0;i<n;i++)
- {
- s1 = NULL;
- s = str[i];
- while(*s)
- {
- if(strchr(chars, *s) != NULL)
- {
- s2 = s - 1;
- while(strchr(chars, *s) != NULL && s) s++;
- if(s2 >= s1 && s1)
- {
- num[*n1] = i;
- strncpy(str1[*n1], s1, s2 - s1 + 1);
- str1[*n1][s2 - s1 + 1] = '\0';
- (*n1)++;
- }
- s1 = s;
- }
- else s++;
- }
- }
- }
- int stroka(char str1[][81], int n1)
- {
- int i, k = -1, l = -1, p;
- char *s;
- for(i=0;i<n1;i++)
- {
- p = 0;
- for(s=str1[i];*s;s++)
- {
- if((int)*s >= 97 && (int)*s <= 122) p++;
- }
- if(p != 0 && p > l) { l = p; k = i; }
- }
- return k;
- }
- int insert(char *s)
- {
- int f = 0, p;
- char *s1, *j;
- for(s1=s;*s1;s1++)
- {
- if((int)*s1 == 32)
- {
- p = 0;
- while((int)*s1 == 32 && s1) {s1++; p++;}
- if(p > 1)
- {
- for(j=s1-p+1;*(j+p-1);j++)
- *(j)=*(j+p-1);
- s1 = s1 - p + 1;
- f = 1;
- s[strlen(s)-p+1] = '\0';
- }
- }
- }
- return f;
- }
- int main()
- {
- int n=0, n1, num[100], i, k;
- char str[10][81], str1[10][81];
- printf("Max: 10 \nPlease, input strings:\n");
- while(n<10 && *gets(str[n])) n++;
- if(n == 0) printf("No strings.");
- else
- {
- substr(str, n, str1, &n1, num);
- printf("\nStrings (%d):\n", n);
- for(i=0;i<n;i++) cout << " " << str[i] << endl;
- if(n1 == 0) printf("\nNo new strings.");
- else
- {
- printf("\nNew Strings (%d):\n", n1);
- for(i=0;i<n1;i++) cout << " " << str1[i] << endl;
- k = stroka(str1, n1);
- if(k == -1) printf("No latin in strings");
- else
- {
- printf("\nFirst string with max latins - %d", k + 1, str1[k]);
- if(insert(str[num[k]]) == 1)
- {
- printf("\nDouble spaces found.");
- printf("\n\nStrings (%d):\n", n);
- for(i=0;i<n;i++) cout << " " << str[i] << endl;
- }
- else printf("\nSpaces weren't deleted.");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement