Advertisement
iletavcioski

Untitled

Nov 20th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. cin>>n;
  7. int i=1;
  8. int j=0;
  9. bool cc=true;
  10. while(1)
  11. {
  12. if(cc)i++;
  13. if(!cc)i--;
  14. j++;
  15. if(i==n)
  16. cc=0;
  17. if(i==1)
  18. cc=1;
  19. if(j==n){cout<<i<<endl;
  20. return 0;
  21. }
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement