Fill in the blank in the following program that draws a figure resembling the letter 'Z' with sides (50, 100, 50) and the angle between them to be 60 degrees.
Remember that the turtle starts at the center of the canvas and facing right.
left(180); forward(50); right(B1); forward(B2); left(B3); forward(50);
#include <iostream>
using namespace std;
int main () {
// the shown of letter z
for (int i = 1; i <= 10; i++) {
if (i == 1 || i == 10) {
for (int j = 1; j < 10; j++) {
cout << "#";
}
cout << endl;
}
else {
for (int j = 1; j < 10; j++) {
if (i + j == 10) {
cout << "#";
}
else {
cout << " ";
}
}
cout << endl;
}
}
// the shown of turtle
for (int i = 1; i <= 11; i++) {
for (int j = 1; j <= 11; j++) {
if (i == j || i + j == 12) {
cout << "#";
}
else {
cout << " ";
}
}
cout << endl;
}
}
Comments
Leave a comment