본문 바로가기
Computer Science/Object Oriented Programming

c++(cpp)_Unit matrix(10*10) 만들기

by hzyiunn 2022. 7. 28.
728x90
반응형
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	int colum = 1, row = 1;
	while(colum < 11)
	{
		while(row < 11)
		{
			int num;
			if(colum == row)
			{
				num = 1;
			}
			else
			{
				num = 0;
			}
			cout << setw(4) << num;
			row += 1;
		}
		cout << endl;
		row = 1;
		colum += 1;
	}
	return 0;
}

 

728x90
반응형

댓글