Algorithm to increase the time limit of enterprise bonus release: 1.0s memory limit: 512.0MBThe bonuses awarded by the Enterprise are based on the profit Percentage. Profit is less than or equal to 100,000 yuan, the bonus can be raised 10%, the profit is higher than 100,000 yuan, less than 200,000 yuan, the portion of less than 100,000 yuan by 10% commission, higher than 100,000 Yuan portion, can commission 7.5%, 200,000 to 400,000, higher than 200,000 yuan of the portion, can commission 5% , between $400,000 and $600,000, which is higher than 400,000 yuan, can be 3%, 600,000 to 1 million, the portion higher than 600,000, which is more than $1.5%, and the portion of more than $1 million is 1 million commission. Enter the month profit from the keyboard, the total bonus should be issued? (reserved two decimal places) profit size within double sample input 210000 sample output 18000.00 author Notes: soil method:
1#include <stdio.h>2#include <string.h>3 intmain () {4 Doublel,j;//L: profit; T: Total Bonus. 5scanf"%LF",&l);6 if(l<=100000){7j=l*0.1;8}Else if(l>100000&& l<=200000){9j=100000*0.1+ (l-100000)*7.5/ -;Tenprintf"%.2LF", j); one}Else if(l>200000&& l<=400000){ aj=100000*0.1+100000*7.5/ -+ (l-200000)*5/ -; -printf"%.2LF", j); -}Else if(l>400000&& l<=600000){ thej=100000*0.1+100000*7.5/ -+200000*5/ -+ (l-400000)*3/ -; -printf"%.2LF", j); -}Else if(l>600000&& l<=1000000){ -j=100000*0.1+100000*7.5/ -+200000*5/ -+200000*3/ -+ (l-600000)*1.5/ -; +printf"%.2LF", j); -}Else if(l>1000000){ +j=100000*0.1+100000*7.5/ -+200000*5/ -+200000*3/ -+400000*1.5/ -+ (l-1000000)*1/ -; aprintf"%.2LF", j); at } - return 0; -}
A little more clever way:
1#include <stdio.h>2 intmain () {3 Doublea;4scanf"%LF",&a);5 Doubleb =0;6 ints[6] = {1000000,600000,400000,200000,100000,0}; 7 Doublet[6] = {0.01,0.015,0.03,0.05,0.075,0.1}; 8 for(inti =0; I <6; i++) { 9 if(a-s[i] >=0) { Tenb + = (a-s[i]) *t[i]; oneA =s[i]; a } - } -printf"%.2LF", b); the return 0; -}
C language · Corporate Bonus Issuance