Advertisement
Guest User

длина слова

a guest
Dec 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <string.h>
  2.  
  3. #define N 1000
  4.  
  5. int main() {
  6.     int lmax;
  7.     int l;
  8.     char smax[5];
  9.     char s[N+1];  
  10.     lmax=0;
  11.     while (scanf("%1000s", s) == 1)
  12.     {
  13.         s[N] = '\0';
  14.         l = strlen (s);
  15.         if (l > lmax)
  16.         {
  17.             lmax = l;
  18.             strcpy (smax,s);
  19.         }              
  20.         printf("+++%s+++ %d\n", s, l);
  21.    };
  22.    
  23.    //printf("hello world");
  24.    printf("%s %d", smax, lmax);
  25.    
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement