1 /* 2 *c語言實現 3 *B11-分支-11. 計算工資(15) 4 *Created on: 2014年6月3日 5 *Author: Boomkeeper 6 *未全部通過 7 * 8 */ 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 13 float salary=0; 14 15 void newStaff(int *worktime) 16 { 17 if(*worktime<=40) 18 { 19 salary=(*worktime)*30; 20 printf("%.2f\n",salary); 21 } 22 else 23 { 24 salary=(*worktime-40)*30*1.5+40*30; 25 printf("%.2f\n",salary); 26 } 27 } 28 29 void oldStaff(int *worktime) 30 { 31 if(*worktime<=40) 32 { 33 salary=(*worktime)*50; 34 printf("%.2f\n",salary); 35 } 36 else 37 { 38 salary=(*worktime-40)*30*1.5+40*50; 39 printf("%.2f\n",salary); 40 } 41 } 42 43 int main() 44 { 45 int workTime=0,workYear=0; 46 int *worktime=&workTime,*workyear=&workYear; 47 48 scanf("%i %i",workyear,worktime); 49 50 if(*worktime<0 || *workyear<0)//小於0的數據不正常 51 exit(0); 52 if(*worktime>(7*24))//一周工作時數超過7*24不正常 53 exit(0); 54 55 if(*workyear<5) 56 newStaff(worktime); 57 else 58 oldStaff(worktime); 59 60 return 0; 61 }