Пирамида из звездочек - C (СИ)
Формулировка задачи:
#include <stdio.h>
main (){
int count, value;
printf ("Введите значение:\n");
scanf ("%d", &value);
if (value <= 0){
printf ("Введенное значение должно быть больше нуля! Завершение программы...\n");
}
if (value >= 1){
printf ("Вы ввели число:\t%d\n", value);
for (value; value >= 1; value--){
}
}
}Решение задачи: «Пирамида из звездочек»
textual
Листинг программы
#include <stdio.h>
void pyramid(FILE* _out, int size, char ch){
int i, j, m1, m2, cx;
char cs[2] = { ' ', ch };
m1 = m2 = (size - 1) * 2 / 2;
cx = size * 2;
for(i = 0; i < size; ++i, --m1, ++m2){
for(j = 0; j < cx; ++j)
fputc(cs[(j >= m1) && (j <= m2)], _out);
fputc('\n', _out);
}
fputc('\n', _out);
}
int main(void){
pyramid(stdout, 4, '+');
pyramid(stdout, 8, '#');
pyramid(stdout, 16, '*');
pyramid(stdout, 28, '.');
return 0;
}