Commit 8c784990 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_06_23' into 'master'

Exercise_06_23, Version1 See merge request bpcarm/trainings2017!1249
parents c608fb6b 67250c51
progname = exercise_06_23
CC = g++
CFLAGS = -Wall -Wextra -Werror -g3
$(progname): $(progname).o | .gitignore
$(CC) $(CFLAGS) $^ -o $@
%.ii: %.cpp
$(CC) -E $(CFLAGS) $< -o $@
%.s: %.ii
$(CC) -S $(CFLAGS) $< -o $@
%.o: %.s
$(CC) -c $(CFLAGS) $< -o $@
.gitignore:
echo $(progname) > $@
clean:
rm -f *.ii *.s *.o *.out $(progname) .gitignore
test: $(progname)
./$(progname) < $@.in > $@.out
diff $@.out $@.expected && echo PASSED || echo FAILED
.PRECIOUS: $(progname).ii $(progname).s
.SECONDARY: $(progname).ii $(progname).s
#include <iostream>
#include <cassert>
void
printSquare(int size1, char character)
{
assert(size1 > 0);
for (int i = 1; i <= size1; ++i) {
for (int j = 1; j <= size1; ++j) {
std::cout << character;
}
std::cout << std::endl;
}
}
int
main()
{
int size;
std::cout << "Enter the size of a square: ";
std::cin >> size;
if (size <= 0) {
std::cerr << "Error 1: Non positive size." << std::endl;
return 1;
}
char character;
std::cout << "Enter a character: ";
std::cin >> character;
printSquare(size, character);
return 0;
}
Enter the size of a square: Enter a character: %%%%%
%%%%%
%%%%%
%%%%%
%%%%%
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