Description
You have started a sales job in a department store.
Your pay consists of a basis salary and a commission. The base salary is $5000.
The scheme shown below is used to determine the commission rate.
Sales Amount Commission Rate
---------------------------------------
$0.01-$5000 8 percent
$5000-$10000 10 percent
$10000.01 and above 12 percent
Your goal is to earn $n
a year. Write a program that finds out the minimum amount
of sales you have to generate in order to make $n
.
Input
The first line is a positive integer t for the number of test cases.
Each test case contains an double value n (0<n<=1000000).
Output
For each test case, outputs the minimum amount of sales you have to generate in order to make $n.
You should specified the floating-point number’s precision to 0 and fixed.
Sample Input
2
30000
60000
Sample Output
210833
460833
Problem Source: 程序设计I Chapter6 Arrays
// Date:2020/4/24
// Author:xiezhg5
#include <stdio.h>
#include <stdlib.h>
//注意数据类型
double Fun(double price) {
double p_rice=price-5000; //减去5000元的基本工资
double sum = 0.0;
//用除法得到原来的数值
//注意分段
if(p_rice< 5000*0.08)
sum += (p_rice-5000)/0.08;
else if( p_rice>= 5000*0.08 && p_rice <= 5000*0.08 + 5000*0.10) {
sum += 5000;
sum += (p_rice-5000*0.08)/0.10;
} else {
sum = sum + 5000;
sum = sum + 5000;
sum = sum + (p_rice - 400 - 500)/0.12;
}
return sum;
}
int main(void) {
int n = 0;
double price[100] = {0.0};
scanf("%d",&n);
for(int i = 0; i < n; i++)
scanf("%lf",&price[i]);
for(int i = 0; i < n; i++)
price[i] = Fun(price[i]); //将最终得到的薪水传入Fun函数中
for(int i = 0; i < n; i++)
printf("%.0lf\n",(double)price[i]);
return 0;
}