[CCF] 201612-2 工资计算
生活随笔
收集整理的這篇文章主要介紹了
[CCF] 201612-2 工资计算
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
【思路】按照題意對初始工資S進行循環,計算繳稅后工資,若與T相等則退出循環,輸出結果。
1 #include <iostream> 2 #include <windows.h> 3 using namespace std; 4 int main() 5 { 6 int T; 7 cin>>T; 8 if(T < 3500) 9 { 10 cout<<T<<endl; 11 return 0; 12 } 13 int x = 0; //扣的錢 14 int S = 200000; //未繳稅的工資 15 int A = S - 3500; 16 while(true) 17 { 18 if(A <= 1500) 19 x = A * 0.03; 20 else if(A <= 4500) 21 x = 45 + (A - 1500) * 0.1; 22 else if(A <= 9000) 23 x = 45 + 300 + (A - 4500) * 0.2; 24 else if(A <= 35000) 25 x = 45 + 300 + 900 + (A - 9000) * 0.25; 26 else if(A <= 55000) 27 x = 45 + 300 + 900 + 6500 + (A - 35000) * 0.3; 28 else if(A <= 80000) 29 x = 45 + 300 + 900 + 6500 + 6000 + (A - 55000) * 0.35; 30 else 31 x = 45 + 300 + 900 + 6500 + 6000 + 8750 + (A - 80000) * 0.45; 32 if(S == x + T) 33 break; 34 S = S - 100; 35 A = S - 3500; 36 } 37 cout<<S<<endl; 38 return 0; 39 }?
轉載于:https://www.cnblogs.com/lca1826/p/6404099.html
總結
以上是生活随笔為你收集整理的[CCF] 201612-2 工资计算的全部內容,希望文章能夠幫你解決所遇到的問題。