1번
*
**
***
****
*****
#include <iostream>
using namespace std;
int main(void)
{
cout << "1번" << endl;
for (int i = 0; i < 5; i++)
{
for ( int j = 0; j <= i; j++)
{
cout << "*";
}
cout << endl;
}
}
2번
*
**
***
****
*****
#include <iostream>
using namespace std;
int main(void)
{
cout << "2번" << endl;
for (int i = 0; i < 5; i++)
{
for (int j = i; j < 4; j++)
{
cout << " ";
}
for (int k = 0; k <= i; k++)
{
cout << "*";
}
cout << endl;
}
}
3번
*****
****
***
**
*
#include <iostream>
using namespace std;
int main(void)
{
cout << "3번" << endl;
for (int i = 0; i < 5; i++)
{
for (int j = 5; j > i; j--)
{
cout << "*";
}
cout << endl;
}
}
4번
*****
****
***
**
*
#include <iostream>
using namespace std;
int main(void)
{
cout << "4번" << endl;
for (int i = 0; i < 5; i++)
{
for (int k = 0; k < i; k++)
{
cout << " ";
}
for (int j = 5; j > i; j--)
{
cout << "*";
}
cout << endl;
}
}
5번
*
***
*****
*******
*********
#include <iostream>
using namespace std;
int main(void)
{
cout << "5번" << endl;
for (int i = 0; i < 5; i++)
{
for (int j = 4 - i; j >= 1; j--)
{
cout << " ";
}
for (int k = 0; k <= i * 2; k++)
{
cout << "*";
}
cout << endl;
}
}
6번
*********
*******
*****
***
*
#include <iostream>
using namespace std;
int main(void)
{
cout << "6번" << endl;
for (int i = 0; i < 5; i++)
{
for (int k = 0; k < i; k++)
{
cout << " ";
}
for (int j = i; j < 9 - i; j++)
{
cout << "*";
}
cout << endl;
}
}
7번
*
***
*****
*******
*********
*******
*****
***
*
#include <iostream>
using namespace std;
int main(void)
{
cout << "7번" << endl;
for (int i = 0; i < 4; i++)
{
for (int j = 4 - i; j >= 1; j--)
{
cout << " ";
}
for (int k = 0; k <= i * 2; k++)
{
cout << "*";
}
cout << endl;
}
for (int i = 0; i < 5; i++)
{
for (int k = 0; k < i; k++)
{
cout << " ";
}
for (int j = i; j < 9 - i; j++)
{
cout << "*";
}
cout << endl;
}
for (int i = 0; i < 9; i++) {
if (i < 5) {
for (int a = i; a < 4; a++)
{
cout << " ";
}
for (int b = 0; b <= i * 2; b++)
{
cout << "*";
}
}
else {
for (int a = 4; a < i; a++)
{
cout << " ";
}
//cout << i;
for (int b = i - 5; b < 12 - i; b++)
{
cout << "*";
}
}
cout << endl;
}
}
[C++] 레퍼런스(Reference) (0) | 2022.05.30 |
---|---|
[C++] 객체 지향 프로그래밍이란? (0) | 2022.05.30 |
[C++] 문법_for 문 (0) | 2022.04.18 |
[C++] 문법_구조체 (0) | 2022.04.15 |
[C++] 콘솔용 탈출 게임 만들어보기(수정 중) (0) | 2022.04.14 |
댓글 영역