Advertisement
Guest User

Untitled

a guest
May 27th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <cstdio>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.   char str [200];
  11.   printf ("string? ");
  12.   fgets (str, 201, stdin);
  13.   int s, max;
  14.   s=0; max=0;
  15.   for (int i=0; ((i<200) && str[i]!=0); i++)
  16.    if (str[i]!=' ') {s++;}
  17.    else if (max<s) {max=s; s=0;}
  18.     else {s=0;}
  19.    printf ("%d", max);
  20.    getchar ();
  21.    return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement