MUstar

IoT C언어 0703 - EX_01

Jul 3rd, 2017
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     char ch;
  6.     int cnt=0, max=0, res;
  7.  
  8.     while(1)
  9.     {
  10.         res = scanf("%c", &ch);
  11.         if (res == -1) break;
  12.         if((ch==10)||(ch==13))
  13.         {
  14.             if(cnt>max) max = cnt;
  15.             cnt=0;
  16.         }
  17.         else cnt++;
  18.     }
  19.     printf("가장 긴 단어의 길어 : %d\n", max);
  20.  
  21.     return 0;
  22. }
RAW Paste Data