Commit c253956d authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_05_29' into 'master'

Exercise_05_29, Version1

See merge request bpcarm/trainings2017!1250
parents add7df07 a193e62e
progname = exercise_05_29
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) > $@.out
diff $@.out $@.expected && echo PASSED || echo FAILED
.PRECIOUS: $(progname).ii $(progname).s
.SECONDARY: $(progname).ii $(progname).s
#include <iostream>
#include <iomanip>
int
main()
{
for (int percent = 5; percent <= 10; ++percent) {
double rate = percent / 100.0;
double amountRate = 1.0 + rate;
double amount = 24.0;
std::cout << std::fixed << "Rate: " << percent << '%' << std::endl
<< "-------------------------------------" << std::endl
<< "Year |" << std::setw(25) << "Amount " << std::endl
<< "-------------------------------------" << std::endl;
for (int year = 1626; year <= 2018; ++year) {
amount *= amountRate;
std::cout << year << std::setw(7) << '|' << std::setw(25) << amount << std::endl;
}
std::cout << "-------------------------------------" << std::endl;
std::cout << std::endl;
}
return 0;
}
This diff is collapsed.
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