0
사용자 입력 옵션을 사용하여 사다리꼴을 만들려고합니다. 내 코드가 최선의 방법은 아닐지도 모르지만 지금까지는 작동합니다! 내 문제는 내가 사다리꼴의 기지 출력 창 왼쪽을 만질 필요합니다. 내가 도대체 뭘 잘못하고있는 겁니까? 다음 동작이 아니라 전체 라인 폭을 설정 setw사용자가 입력 한 문자를 사용하여 사다리꼴 만들기. (Console App)
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int topw, height, width, rowCount = 0, temp;
char fill;
cout << "Please type in the top width: ";
cin >> topw;
cout << "Please type in the height: ";
cin >> height;
cout << "Please type in the character: ";
cin >> fill;
width = topw + (2 * (height - 1));
cout<<setw(width);
for(int i = 0; i < topw;i++)
{
cout << fill;
}
cout << endl;
rowCount++;
width--;
temp = topw + 1;
while(rowCount < height)
{
cout<<setw(width);
for(int i = 0; i <= temp; i++)
{
cout << fill;
}
cout << endl;
rowCount++;
width--;
temp = temp +2;
}
}
인가 :
또한, 일부 중복 코드를 시도있을 것 같습니다? – Xorlev
"최고의 사다리꼴"은 무엇을 의미합니까? –