Lỗi khi vẽ mũi tên bằng vòng lặp for trong c++

Mình đang bí làm sao để làm hoàn chỉnh mũi tên
đây là đề bài

Và đây là code của mình

#include <iostream>
#include <string>
using namespace std;
int main() {
	int height = 13;
	int width = 22;
	//cout << "Enter height of arrow: ";
	//cin >> height;
	//cout << "Enter width of arrow: ";
    //cin >> width;
    for (int i = 1 ; i <= height;i++){
        for(int j = 1; j <= width; j++){
            if(i < 6|| i > 8) cout <<" " ;else cout << "*";
        }
       for(int k =1; k<=height;k++){
           if (k<2)
            for(int w = 1 ; w <= i ; w++){
            cout << "*";
           }
        }
        cout <<endl;
    }
}
for(int i = 1; i <= (height-3)/2; i++) {
	printStar(i);
}
printStar(width-1);
printStar(width);
printStar(width-1);
for(int i = (height-3)/2; i >=1; i--) {
	printStar(i);
}

void printStar(int n) {
	for(int i=0; i < n; i++){
		cout<<"*";
	}
	cout<<endl;
}
2 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?