Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n, i = 0, j = 0, t;
  7.  
  8. cin >> n;
  9.  
  10. char a[n][n];
  11.  
  12.  
  13. while (i < n) {
  14.  
  15. while (j < n) {
  16.  
  17.  
  18. if (i != (n - 1)/2 && j != (n - 1)/2) {
  19.  
  20.  
  21. if(j == i || j == n - 1 - i) {
  22.  
  23. *((char*) a + i*n + j) = '*';
  24.  
  25. }
  26.  
  27. else {
  28.  
  29. *((char*) a + i*n + j) = ' ';
  30.  
  31. }
  32.  
  33. }
  34.  
  35. else {
  36.  
  37. *((char*) a + i*n + j) = '*';
  38.  
  39.  
  40. }
  41.  
  42. j++;
  43.  
  44.  
  45. }
  46. j = 0;
  47.  
  48. i++;
  49.  
  50. }
  51.  
  52. i = 0;
  53.  
  54.  
  55. while (i < n) {
  56.  
  57.  
  58. while (j < n) {
  59.  
  60. cout << *((char*) a + i*n +j) << " ";
  61. j++;
  62. }
  63.  
  64. cout << "\n";
  65.  
  66. j = 0;
  67.  
  68. i++;
  69.  
  70. }
  71.  
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement