Commit 51b8b7e0 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'ex7.10' into 'master'

exercise_07_10

See merge request bpcarm/trainings2017!1410
parents 111c0aed f211c7bc
progname=exercise_07_10
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)
echo process is executing...
./$(progname) < $@.in > $@.out || echo "negative case"
diff $@.out $@.expected && echo PASSED || echo FAILED
.PRECIOUS: $(progname).ii $(progname).s
.SECONDARY: $(progname).ii $(progname).s
#include<iostream>
int
main()
{
const int FREQUENCY_SIZE = 9;
int wageFrequency[FREQUENCY_SIZE] = {0};
while (true) {
int weeklySelling;
std::cout << "Input weekly selling or -1 to exit: ";
std::cin >> weeklySelling;
if (-1 == weeklySelling) {
std::cout << std::endl;
break;
}
int wage = ((weeklySelling * 9) / 100 + 200);
++wageFrequency[wage / 100 - 2];
std::cout << std::endl;
}
int count;
for (count = 0; count < FREQUENCY_SIZE - 1; ++count) {
const int wageSizeFrom = (count + 2) * 100;
const int wageSizeTo = wageSizeFrom + 99;
std::cout << wageSizeFrom << "$" << "-" << wageSizeTo << "$: ";
std::cout << wageFrequency[count] << std::endl;
}
std::cout << "1000$ and more: ";
std::cout << wageFrequency[count] << std::endl;
return 0;
}
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
Input weekly selling or -1 to exit:
200$-299$: 0
300$-399$: 0
400$-499$: 2
500$-599$: 3
600$-699$: 3
700$-799$: 1
800$-899$: 0
900$-999$: 1
1000$ and more: 0
5000
4000
6000
2500
4800
3650
4260
2860
4780
8200
-1
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