Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int poisk(char* str, int ch) {
- int i = 0;
- while (str[i]) {
- if (str[i] == ch) {
- return i;
- }
- i++;
- }
- return -1;
- }
- int minim(char* str) {
- int i = 0;
- int min = 1000;
- int inword = 1;
- int c = 0;
- char sep[] = " ,.!?\n\t\0";
- while (str[i]) {
- if (poisk(sep, str[i]) != -1) {
- if (inword) {
- if (c < min && c != 0) {
- min = c;
- }
- c = 0;
- inword = 0;
- }
- }
- else {
- c++;
- inword = 1;
- }
- i++;
- }
- if (inword) {
- if (c < min && c != 0) {
- min = c;
- }
- }
- return min;
- }
- int main()
- {
- int const size = 50;
- char str[size] = " ";
- char str1[size];
- int i = 0;
- int min = 1000;
- while (str[0] != '\n') {
- fgets(str, size, stdin);
- if (minim(str) < min) {
- min = minim(str);
- while (str[i] != '\n') {
- str1[i] = str[i];
- i++;
- }
- str1[i] = '\0';
- i = 0;
- }
- }
- printf("%s", str1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement