Commit bf8a4a24 authored by Believer Programmers' Club's avatar Believer Programmers' Club

Merge branch 'branch6.33' into 'master'

michael.davityan:exercise_06_33

See merge request bpcarm/trainings2017!905
parents 669a9339 83d73d8d
progname=exercise_06_33
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1 test2 test3 test4 test5 test6 test7 test8
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
debug/%.o: debug/%.s
$(CC) -c $(CFLAGS) $< -o $@
debug/%.s: debug/%.ii
$(CC) -S $(CFLAGS) $< -o $@
debug/%.ii: %.cpp | debug
$(CC) -E $(CFLAGS) $< -o $@
debug:
mkdir -p debug
clean:
rm -r debug Tests/*.out
test%: debug/$(progname)
@./debug/$(progname) < Tests/$@.in > Tests/$@.out 2>&1 || echo "$@ is executing..."
@diff Tests/$@.out Tests/$@.expected && echo PASSED || echo FAILED
.PRECIOUS: debug/%.ii debug/%.s
.SECONDARY: debug/%.ii debug/%.s
#include <iostream>
#include <unistd.h>
#include <cassert>
int qualityPoints(const int averageGrade);
int
main()
{
if (::isatty(STDIN_FILENO)) {
std::cout << "Input student average: ";
}
int averageGrade;
std::cin >> averageGrade;
if ((averageGrade < 0) || (averageGrade > 100)) {
std::cerr << "Error 1: must be more than 0 or less than 100.\n";
return 1;
}
std::cout << qualityPoints(averageGrade) << std::endl;
return 0;
}
int
qualityPoints(const int averageGrade)
{
assert((averageGrade >= 0) && (averageGrade <= 100));
if (100 == averageGrade) {
return 4;
}
int result = averageGrade / 10 - 5;
return (result > 0 ? result : 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