Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. char mem[1005];
  5. int mp[25][1005];
  6. int main()
  7. {
  8. int n;
  9. cin >> n;
  10. cin >> mem;
  11. // cout << mem;
  12. int loop,cntx=n-1,cnty=0,cnt=1;
  13. loop=strlen(mem)/(4*n-4);
  14. for(int i=0;i<=loop;i++)
  15. {
  16. for(int j=0;j<n;j++)
  17. {
  18. // cout << "hey" << endl;
  19. mp[cntx--][cnty]=1;
  20. cnt++;
  21. if(cnt==strlen(mem)+1) break;
  22.  
  23. }
  24. if(cnt==strlen(mem)+1) break;
  25. cntx++;
  26. cnty++;
  27. for(int j=0;j<n-1;j++)
  28. {
  29. mp[cntx][cnty++]=1;
  30. cnt++;
  31. if(cnt==strlen(mem)+1) break;
  32. // cout << "2hey" << endl;
  33. }
  34. if(cnt==strlen(mem)+1) break;
  35. cnty--;
  36. cntx++;
  37. for(int j=0;j<n-1;j++)
  38. {
  39. mp[cntx++][cnty]=1;
  40. cnt++;
  41. if(cnt==strlen(mem)+1) break;
  42. }
  43. if(cnt==strlen(mem)+1) break;
  44. cntx--;
  45. cnty++;
  46. for(int j=0;j<n-2;j++)
  47. {
  48. mp[cntx][cnty++]=1;
  49. cnt++;
  50. if(cnt==strlen(mem)+1) break;
  51. }
  52. if(cnt==strlen(mem)+1) break;
  53. }
  54. cntx=0;
  55. // for(int i=0;i<5;i++)
  56. // {
  57. // for(int j=0;j<40;j++)
  58. // {
  59. // if(mp[i][j]) cout << mp[i][j];
  60. // else cout << ".";
  61. // }
  62. // cout << endl;
  63. // }
  64. for(int i=0;i<n;i++)
  65. {
  66. for(int j=0;j<1005;j++)
  67. {
  68. if(mp[i][j]) mp[i][j]=mem[cntx++];
  69. if(!mem[cntx])break;
  70. }
  71. if(!mem[cntx])break;
  72. }
  73. // for(int i=0;i<n;i++)
  74. // {
  75. // for(int j=0;j<1005;j++)
  76. // {
  77. // if(mp[i][j]) printf("%c",mp[i][j]);
  78. // else cout << ".";
  79. // }
  80. // cout << endl;
  81. // }
  82. cntx=n-1,cnty=0;
  83. for(int i=0;i<=loop;i++)
  84. {
  85.  
  86. for(int j=0;j<n;j++)
  87. {
  88. printf("%c",mp[cntx--][cnty]);
  89. }
  90. cntx++;
  91. cnty++;
  92. for(int j=0;j<n-1;j++)
  93. {
  94. printf("%c",mp[cntx][cnty++]);
  95.  
  96. }
  97. cnty--;
  98. cntx++;
  99. for(int j=0;j<n-1;j++)
  100. {
  101. printf("%c",mp[cntx++][cnty]);
  102. }
  103. cntx--;
  104. cnty++;
  105. for(int j=0;j<n-2;j++)
  106. {
  107. printf("%c",mp[cntx][cnty++]);
  108. }
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement