Ответ 1
Поздравляем вас с началом программирования в таком молодом возрасте! Многие взрослые испугались изучения С++, потому что это должно быть супер сложно, но я думаю, что здорово, что вы пытаетесь изучить его в таком молодом возрасте. Я тоже начал учиться программированию - мне было 7 лет. Это было до того, как С++ даже существовал, поэтому мой первый язык был assembler на TRS-80 Model I:
Я уже старый, как грязь, или, по крайней мере, мой девятилетний сын говорит мне об этом, и я программирую на С++ для жизни и люблю его. Итак, продолжайте!
Во всяком случае, я не уверен, что вы пытаетесь сделать точно, но это звучит как одна из моих первых программ (которые печатали "BEAUTY EH?" на экране в огромной графике. Нарисовать знак вопроса было очень сложно.). Но вот программа, которая отображает окно, подобное этому:
********************************************************************************
* *
* *
* *
* *
* *
* *
* *
* *
********************************************************************************
И вот программа:
#include <cstdlib> // It always best to include this file before any others.
#include <iostream> // This is so we can use "cout"
int main()
{
// first let save ourselves a little typing
using namespace std;
// We're going to draw a box of stars ("*").
// It will be 80 characters wide by 10 rows tall.
//
// Since we're writing to the console using 'cout',
// we're just going to write one line at a time,
// and then issue a carraige return to start printing
// on the next line.
// First let draw the top "wall", which is a solid
// row of 80 stars, one at a time
for (int column = 0; column < 80; ++column)
{
cout << "*";
}
// now print a carraige return, so we can start printing on the next line
cout << "\n";
// Now we're going to print the sides.
// There are 8 rows here. Each row is a star, followed by
// 78 spaces, followed by another star and a carraige return.
for (int row = 0; row < 8; ++row)
{
// print the left "wall"
cout << "*";
// now print 78 spaces
for (int column = 0; column < 78; ++column)
{
cout << " ";
}
// finally print the right "wall" and a carraige return
cout << "*\n";
// continue the for loop to print the next row
}
// Once the loop is done, we can print the bottom wall the same way we printed the top one.
for (int column = 0; column < 80; ++column)
{
cout << "*";
}
// now print a carraige return, so we can start printing on the next line
cout << "\n";
}