Commit a25e163e authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_31' into 'master'

exercise_06_31, version1

See merge request bpcarm/trainings2017!1337
parents c253956d 88687ea2
progname = exercise_06_31
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>
int
reverse(const int number)
{
int numberCopy = number;
int reversed = 0;
while (numberCopy > 0) {
int reminder = numberCopy % 10;
reversed = reversed * 10 + reminder;
numberCopy /= 10;
}
return reversed;
}
int
main()
{
int number;
std::cout << "Enter a number ";
std::cin >> number;
std::cout << "Reversed number is " << reverse(number) << 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