Commit 5262393d authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'Bbranch5.24' into 'master'

michael.davityan:exercise_05_24v3

See merge request bpcarm/trainings2017!1375
parents dfc9fdd9 b2eda196
Pipeline #30886953 failed with stage
in 1 minute and 34 seconds
progname=exercise_05_24
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1 test2 test3 test4 test5
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
debug/%.o: debug/%.s
$(CC) -c $(CFLAGS) $< -o $@
debug/%.s: debug/%.ii
$(CC) -S $(CFLAGS) $< -o $@
debug/%.ii: %.cpp | debug
$(CC) -E $(CFLAGS) $< -o $@
debug:
mkdir -p debug
clean:
rm -r debug Tests/*.out
test%: debug/$(progname)
@./debug/$(progname) < Tests/$@.in > Tests/$@.out 2>&1 || echo "$@ is executing..."
@diff Tests/$@.out Tests/$@.expected && echo PASSED || echo FAILED
.PRECIOUS: debug/%.ii debug/%.s
.SECONDARY: debug/%.ii debug/%.s
*
***
*****
*******
*********
***********
*************
***************
*************
***********
*********
*******
*****
***
*
Error 1: wrong size value (must be odd number from 1->19).
Error 1: wrong size value (must be odd number from 1->19).
Error 1: wrong size value (must be odd number from 1->19).
#include <iostream>
#include <unistd.h>
#include <cmath>
int
main()
{
int rhombusSize;
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert rhombus size (must be odd number from 1->19): ";
}
std::cin >> rhombusSize;
if (rhombusSize % 2 == 0 || rhombusSize < 1 || rhombusSize > 19) {
std::cerr << "Error 1: wrong size value (must be odd number from 1->19).\n";
return 1;
}
const int rowLimit = rhombusSize / 2;
for (int row = -rowLimit; row <= rowLimit; ++row) {
const int starStart = rowLimit - std::abs(row);
for (int column = -rowLimit; column <= starStart; ++column) {
std::cout << (column < -starStart ? " " : "*");
}
std::cout << std::endl;
}
return 0;
}
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