일단 변수 세개 쓰면서 개억지로 풀긴 했는데

문제로 나오기엔 코드가 너무 더러워서 다른 방법 있나 여쭤봅니다

구글링해봐도 while문만 쓰는 조건은 잘 없네요


#include <iostream>

using namespace std;


int main(){

int size{0}, sizestore{0}, temp{0};

cin >> size;

temp = size;

sizestore = size;

while (temp > 0){

cout << "*";

temp--;

}

cout << endl;

temp = sizestore;

while (size > 2){

cout << "*";

while (temp > 2){

cout << " ";

temp--;

}

cout << "* ";

size--;

temp = sizestore;

}

if (temp == 1){

}

else{

while (temp > 0){

cout << "*";

temp--;

}

}

}