Advertisement
askarulytarlan

spiral

Oct 8th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <math.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int n;
  10.  
  11. int main(int argc, const char * argv[]) {
  12.  
  13. cin >> n;
  14. int y = 1;
  15. int k = 17;
  16. int c = n - 1;
  17. int m = n * 3 - 2;
  18. for (int i = 1 ; i <= n - 1 ; i++ ){
  19. for(int j = y ; j <= y + c ; j++ ){
  20. cout << j << " ";
  21. }
  22. cout << endl ;
  23. y = y + c;
  24. c = c - 1;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement