일단 변수 세개 쓰면서 개억지로 풀긴 했는데
문제로 나오기엔 코드가 너무 더러워서 다른 방법 있나 여쭤봅니다
구글링해봐도 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--;
}
}
}
xy로 루프돌고 if x or y = 1 or size 이면 별 찍으면 되는거 아닌가
while(cond) stmt; break; 하면 if문 대체 가능 ㅋㅋ