Skip to content

Instantly share code, notes, and snippets.

@m1irka
Created October 24, 2024 11:26
Show Gist options
  • Select an option

  • Save m1irka/634be038d06de6416b576000863979b1 to your computer and use it in GitHub Desktop.

Select an option

Save m1irka/634be038d06de6416b576000863979b1 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
/*
Enter rows: 4
Enter cols: 4
0 0 0 0
1 1 1 1
0 0 0 0
1 1 1 1
*/
int main() {
int rows, cols;
cout << "Enter rows: ";
cin >> rows;
cout << "Enter cols: ";
cin >> cols;
if (rows == cols)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
if (i%2)
{
cout << 1 << " ";
}
else
{
cout << 0 << " ";
}
}
cout << endl;
}
}
else
{
cout << "Error. Good bye ;p";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment