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

Merge branch 'exe_07_10' into 'master'

Aro Ghukasyan Exe 07 10 Ship it

See merge request bpcarm/trainings2017!1433
parents ebef33d0 a97b5867
progname=exercise_07_10
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1
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
If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale: If you want break Enter -1 Enter Week Sale:
1. $200 - 299 10
2. $300 - 399 0
3. $400 - 499 1
4. $500 - 599 1
5. $600 - 699 1
6. $700 - 799 2
7. $800 - 899 1
8. $900 - 999 1
9. $1000 and more 3
100
200
300
400
500
500
500
4000
6000
7000
9000
8000
1000
1000
1000
3000
5890
99999
70000
4500
-1
#include <iostream>
void getSalaries(int * array, int ARRAY_SIZE);
int
main()
{
const int ARRAY_SIZE = 9;
int arrayCount[ARRAY_SIZE] = {0};
getSalaries(arrayCount, ARRAY_SIZE);
std::cout << std::endl;
for (int i = 0; i < ARRAY_SIZE - 1; ++i) {
const int rangeOfnumber = 100 * (i + 2);
std::cout << i + 1 << ". $" << rangeOfnumber << " - " << rangeOfnumber + 99 << "\t";
std::cout << "\t" << arrayCount[i];
std::cout << std::endl;
}
std::cout << "9. $1000 and more ";
std::cout << "\t" << arrayCount[ARRAY_SIZE - 1];
std::cout << std::endl;
return 0;
}
void
getSalaries(int* array, int ARRAY_SIZE)
{
do
{
std::cout << "If you want break Enter -1 \t Enter Week Sale: ";
int sale;
std::cin >> sale;
if (-1 == sale) {
break;
}
if (-1 > sale) {
std::cerr << "\nError 1: Sale can not be negative." << std::endl;
break;
}
const int allSalary = (sale * 9 / 100) + 200;
if (1000 < allSalary) {
++array[ARRAY_SIZE - 1];
} else {
++array[allSalary / 100 - 2];
}
} while (true);
}
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