Commit fdddfabd by Karine

Exercise_05_24, Version1

parent 9daac871
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>
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;
int space = row - 1;
for (int i = 1; i <= row; i++) {
for (int j = 1; j <= space; j++) {
std::cout << " ";
}
space--;
for (int j = 1; j <= 2 * i - 1; j++) {
std::cout << "*";
}
std::cout << std::endl;
}
space = 1;
for (int i = 1; i <= row; i++) {
for (int j = 1;j <= space; j++) {
std::cout << " ";
}
space++;
for (int j = 1; j <= 2 * (row - i) - 1; j++) {
std::cout << "*";
}
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