Commit 3837e406 authored by Karine's avatar Karine

Exercise_05_10, Version1

parent 9daac871
exercise_05_10: 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_10" > $@
clean:
rm *.ii *.s *.o *.out exercise_05_10 .gitignore
test: exercise_05_10
@./exercise_05_10 > 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 factorial = 1;
for (int i = 1; i <= 5; ++i) {
factorial *= i;
std::cout << i << "'s factorial is " << factorial << std::endl;
}
return 0;
}
20's factorial is a big number and can't be stored in 4byte.
1's factorial is 1
2's factorial is 2
3's factorial is 6
4's factorial is 24
5's factorial is 120
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