Advertisement
srtgguy

Untitled

May 15th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int number(int x)
  5. {
  6.     int a=1, j=0, z=1, g=0;
  7.     while (x>a)
  8.     {
  9.         j=a;
  10.         a+=z;
  11.         z++;
  12.     }
  13.     if(a==x)
  14.     {
  15.         g=1;
  16.     }
  17.     return g;
  18. }
  19.  
  20. using namespace std;
  21.  
  22. int main()
  23. {
  24.     int n, x;
  25.     cin>>n;
  26.     const int N=n;
  27.     int A[N];
  28.     for(int i=0; i<N; i++)
  29.     {
  30.         cin>>x;
  31.         A[i]=number(x);
  32.     }
  33.     for(int i=0; i<N; i++)
  34.     {
  35.         cout<<A[i]<<" ";
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement