AddO1f

Lab6_1

Nov 5th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "string.h"
  3. #include "iostream"
  4. #include "iomanip"
  5. #include "math.h"
  6.  
  7. using namespace std;
  8.  
  9. int _tmain(int argc, _TCHAR* argv[])
  10. {
  11.     char st[40];
  12.     int i,j,n,k;
  13.     cout<<"Enter posledov:";
  14.     cin.getline(st, 39);
  15.     j=strlen(st);
  16.     n=k=i=0;
  17.     while (i<j)
  18.     {
  19.         if ((st[i]==' ') && (n==5))
  20.         {k=k+1; n=0;}
  21.         else if (st[i]==' ')
  22.         {n=0;}
  23.         else n++;
  24.         i++;
  25.     }
  26.     if (n==5) {k=k+1;}
  27.     cout<<k<<endl;
  28.     system("pause");
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment