AddO1f

Lab5_2

Oct 11th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "iomanip"
  4. #include "math.h"
  5.  
  6. using namespace std;
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10.         double n,i,k,l;
  11.         k=l=0;
  12.         cout<<"Enter n=";
  13.         cin>>n;
  14.         while ((n>=4) && (l<3))
  15.         {
  16.                 i=n/4;
  17.                 if (i-int(i)==0) {k=k+n; l++; n=n-4;}
  18.                 else n--;
  19.         }
  20.         cout<<k<<endl;
  21.         system("pause");
  22.         return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment