evgenko

sasha_lab_9

Dec 10th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <memory.h>
  3.  
  4. int main(){
  5.     char string1[100];
  6.     fgets(string1,sizeof(string1),stdin);
  7.     int lenth = 0;
  8.     int minlenth = strlen(string1);
  9.     for (int i=strlen(string1)-2;i>=0;i--){
  10.         lenth++;
  11.         if (string1[i]==' '){
  12.             lenth-=1;
  13.             if (minlenth>lenth)
  14.                 minlenth = lenth;
  15.             lenth = 0;
  16.  
  17.             for (int j=i+1;string1[j]!=' '&& string1[j]!='\n';j++){
  18.                 printf("%c",string1[j]);
  19.             }
  20.             printf(" ");
  21.         }
  22.         if (i==0){
  23.             if (minlenth>lenth) {
  24.                 minlenth = lenth;
  25.             }
  26.             for (int j=i;string1[j]!=' '&& string1[j]!='\n';j++){
  27.                 printf("%c",string1[j]);
  28.             }
  29.         }
  30.  
  31.     }
  32.  
  33.     printf("\n%d",minlenth);
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment