Другие языки программирования и технологии

специалисты помогите с++

Помогите решить в, ж, и. Дальше я сам. Нужно решение циклами for и if else.
for (Str = 0; Str < 10; Str++)
{
for (x = 0; x < 10; x++)
{
if (x < Str)
cout << " ";
else
cout << "*";
}
cout << "\n";
}

//2
for (Str = 0; Str < 10; Str++)
{
for (x = 0; x < 10; x++)
{
if (x > Str)
cout << " ";
else
cout << "*";
}
cout << "\n";

}
Первые два решил. Эти никак не пойму. Спасибо заранее.
Илья Бугор
Илья Бугор
93
#include <iostream>
using namespace std;
int main() {
setlocale(LC_CTYPE, "Russian");
const auto n = 9U;
const auto l = n - 1U;
const char a = '*', s = ' ';
unsigned x;
do {
cout << "Введите значение от 0 до 9: ";
cin >> x;
system("cls");
switch (x) {
case 0:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) cout << (i >= j? a : s);
cout.put('\n');
}
break;
case 1U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) cout << (i <= j? a : s);
cout.put('\n');
}
break;
case 2U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) cout << (i + j >= l? a : s);
cout.put('\n');
}
break;
case 3U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) cout << (i + j <= l? a : s);
cout.put('\n');
}
break;
case 4U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j)
if (i < n / 2U) cout << (i >= j? a : s);
else cout << (i + j <= l? a : s);
cout.put('\n');
}
break;
case 5U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j)
if (i < n / 2U) cout << (i + j >= l? a : s);
else cout << (i > j? s : a);
cout.put('\n');
}
break;
case 6U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j)
if (j < n / 2U) cout << (i <= j? a : s);
else cout << (i + j <= l? a : s);
cout.put('\n');
}
break;
case 7U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j)
if (j < n / 2U) cout << (i + j >= l? a : s);
else cout << (i >= j? a : s);
cout.put('\n');
}
break;
case 8U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) {
if (i <= n / 2U) cout << (i >= j || i + j >= l? a : s);
else cout << (i + j <= l || i <= j? a : s);
}
cout.put('\n');
}
break;
case 9U:
for (auto i = 0U; i < n; ++i) {
for (auto j = 0U; j < n; ++j) {
if (j < n / 2U) cout << (i <= j || i + j >= l? a : s);
else cout << (i + j <= l || i >= j? a : s);
}
cout.put('\n');
}
break;
default: break;
}
} while (x < 10U);
}
Герман Чернышев
Герман Чернышев
62 351
Лучший ответ
Илья Бугор Благодарю.