[請問] 一題C語言
※ [本文轉錄自 ask 看板 #1DXW64u3 ]
作者: supercygnus (......) 看板: ask
標題: [請問] 一題C語言
時間: Sun Mar 20 21:30:41 2011
#include <stdio.h>
#include <stdlib.h>
int main (void){
float x;
float s=0.0f;
printf("請輸入工作時數");
scanf("%f",&x);
printf("%.1f",x);
if(x<=60){
s+=x*75;
printf("薪資為:%.3f\n",s);
}
else if(60<x<=75){
s+=60*75+(x-60)*75*1.25;
printf("薪資為:%.3f\n",s);
}
else if(x>75){
s+=60*75+15*75*1.25+(x-75)*75*1.75;
printf("薪資為:%.3f\n",s);
}
system("pause");
return 0;
}
我工作時數用80輸入,跑出的結果是6375.000
但是正確新資是6562.5
為什麼我跑不出正確結果= =
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.167.108.56
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.167.108.56
→
03/20 21:41, , 1F
03/20 21:41, 1F
→
03/20 21:42, , 2F
03/20 21:42, 2F
→
03/20 21:46, , 3F
03/20 21:46, 3F
→
03/20 21:46, , 4F
03/20 21:46, 4F
→
03/20 21:49, , 5F
03/20 21:49, 5F
→
03/21 16:59, , 6F
03/21 16:59, 6F
→
03/21 16:59, , 7F
03/21 16:59, 7F