Advertisement
Ne-Biolog

Untitled

Jun 15th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. using namespace std;
  6. int i,n,m,l,k,s,r;
  7. int a[100][100];
  8.  
  9. int main ( )
  10. {
  11. ifstream read_file("input.txt");
  12. ofstream write_file("output.txt");
  13. cin>>n;
  14. r=0;
  15. while (k!=n*n)
  16. {
  17. r++;
  18. for(i=r;i<n-r+1;i++)
  19. {
  20. k++;
  21. a[r][i]=k;
  22. cout<<k<<endl;
  23. }
  24. for(i=r+1;i<n-r+1;i++)
  25. {
  26. k++;
  27. a[i][n-r+1]=k;
  28. cout<<k<<endl;
  29. }
  30. for(i=n-r;i>r;i--)
  31. {
  32. k++;
  33. a[n-s+1][i]=k;
  34. cout<<k<<endl;
  35. }
  36. for(i=n-r;i>r+1;i--)
  37. {
  38. k++;
  39. a[i][r]=k;
  40. cout<<k<<endl;
  41. }
  42.  
  43. }
  44. for(i=0;i<n;i++)
  45. {
  46.  
  47. for(m=0;m<n;m++)
  48. {
  49. cout<<" "<<a[i][m];
  50.  
  51. }
  52. cout<<""<<endl;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement