Commit dbe7759f by Artak Yenokyan

Merge branch 'exe_05_18' into 'master'

Exercise_05_18, Version1 See merge request bpcarm/trainings2017!1209
parents 1622cbd9 54dfcb79
exercise_05_18: main.o | .gitignore
g++ $^ -o $@
%.ii: %.cpp
g++ -E $^ -o $@
%.s: %.ii
g++ -S $^ -o $@
%.o: %.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_18" > $@
clean:
rm *.ii *.s *.o *.out exercise_05_18 .gitignore
test: exercise_05_18
@./exercise_05_18 > 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
dbg: debug/exercise_05_18
debug/exercise_05_18: debug/main.o | .gitignore
g++ -Wall -Wextra -Werror -g3 $^ -o $@
debug/main.o: debug/main.s
g++ -c -Wall -Wextra -Werror -g3 $^ -o $@
debug/main.s: debug/main.ii
g++ -S -Wall -Wextra -Werror -g3 $^ -o $@
debug/main.ii: main.cpp | debug
g++ -E -Wall -Wextra -Werror -g3 $^ -o $@
debug:
mkdir -p debug
#include <iostream>
int
main()
{
for (int number = 1; number <= 256; number++) {
int index = 1;
int counter = number;
int binary = 0;
while (counter != 0) {
int binaryCharacter = counter % 2;
counter /= 2;
binary += binaryCharacter * index;
index *= 10;
}
std::cout << "decimal: " << std::dec << number << "\t"
<< " | binary: " << binary << "\t"
<< " | octal: " << std::oct << number << "\t"
<< " | hexadecimal: " << std::hex << number << "\t"
<< 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