Skip to content

Instantly share code, notes, and snippets.

@vlaleli
Created October 28, 2024 18:22
Show Gist options
  • Select an option

  • Save vlaleli/36b4f9380236bd42c29b35f38c8b60d8 to your computer and use it in GitHub Desktop.

Select an option

Save vlaleli/36b4f9380236bd42c29b35f38c8b60d8 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter size: ";
cin >> n;
int matrix[30][30];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (i == n / 2 || j == n / 2)
{
matrix[i][j] = 1;
}
else
{
matrix[i][j] = 0;
}
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
cout << matrix[i][j] << " ";
}
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment