Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

XOR삼각형/곽세환: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Repair batch-0004 pages from live compare)
 
Line 4: Line 4:
  int main()
  int main()
  {
  {
  int ar[10][10]={{0}};
  int ar[10][10]={{0}};
  for (int k = 0; k < 10 - 1; k++)
  for (int k = 0; k < 10 - 1; k++)
  cout << " ";
  cout << " ";
  ar[0][0] = 1;
  ar[0][0] = 1;
  cout << ar[0][0] << endl;
  cout << ar[0][0] << endl;
  for (int i = 1; i < 10; i++)
  for (int i = 1; i < 10; i++)
  {
  {
Line 16: Line 16:
  {
  {
  if (j == 0)
  if (j == 0)
  ar[i][j] = 1;
  ar[i][j] = 1;
  else
  else
  ar[i][j] = (ar[i-1][j] == ar[i-1][j-1]) ? 0 : 1;
  ar[i][j] = (ar[i-1][j] == ar[i-1][j-1]) ? 0 : 1;
  cout << ar[i][j] << " ";
  cout << ar[i][j] << " ";
  }
  }
  cout << "\n";
  cout << "\n";
Line 26: Line 26:
  return 0;
  return 0;
  }
  }

Latest revision as of 00:37, 27 March 2026

#include <iostream>
using namespace std;

int main()
{
	int ar[10][10]=Template:0;
	for (int k = 0; k < 10 - 1; k++)
		cout << " ";
	ar[0][0] = 1;
	cout << ar[0][0] << endl;
	for (int i = 1; i < 10; i++)
	{
		for (int k = 0; k < 10 - 1 - i; k++)
			cout << " ";
		for (int j = 0; j < i + 1; j++)
		{
			if (j == 0)
				ar[i][j] = 1;
			else
				ar[i][j] = (ar[i-1][j] == ar[i-1][j-1]) ? 0 : 1;
			cout << ar[i][j] << " ";
		}
		cout << "\n";
	}
	
	return 0;
}