Commit 1cf02b42 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_24' into 'master'

Exercise_05_24, Version1 See merge request bpcarm/trainings2017!1204
parents 5cef287c 84f76b9c
exercise_05_24: main.o | .gitignore
g++ $^ -o $@
main.ii: main.cpp
g++ -E $^ -o $@
main.s: main.ii
g++ -S $^ -o $@
main.o: main.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_24" > $@
clean:
rm *.ii *.s *.o *.out exercise_05_24 .gitignore
test: exercise_05_24
@./exercise_05_24 < test.in > test.out
@diff test.out test.expected > /dev/null 2>&1 && echo PASSED || echo FAILED
.PRECIOUS: main.ii main.s
.SECONDARY: main.ii main.s
#include <iostream>
#include <cmath>
int
main()
{
int row;
std::cout << "Enter the odd count of rows (from 1 to 19): ";
std::cin >> row;
if(row % 2 == 0) {
std::cerr << "Error 1: Even number was inputed." << std::endl;
return 1;
}
std::cout << std::endl;
row /= 2;
for (int i = -row; i <= row; ++i) {
for (int j = -row; j <= row; ++j) {
std::cout << ((std::abs(i) + std::abs(j) <= row) ? "*" : " ");
}
std::cout << std::endl;
}
return 0;
}
Enter the odd count of rows (from 1 to 19):
*
***
*****
*******
*********
***********
*************
***************
*************
***********
*********
*******
*****
***
*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment