c语言 求解
答案:2 悬赏:80 手机版
解决时间 2021-01-20 17:17
- 提问者网友:浩歌待明月
- 2021-01-20 14:12
c语言 求解
最佳答案
- 五星知识达人网友:渡鹤影
- 2021-01-20 14:56
#include
#include
int main()
{
int startTimeOf0am=0,startTimeOf8am=8*60,startTimeOf6pm=18*60,startTimeOf24pm=24*60;
int startTime,durationTime,dayOfWeek;
int duration,endTime;
float cost=0;
while(1)
{
printf("Enter the start time, duration and day of the week:(-1 to exit)");
scanf("%d %d %d",&startTime,&durationTime,&dayOfWeek);
if(startTime<0||startTime>=24*60||durationTime<0||dayOfWeek<0||dayOfWeek>7)
{
printf("Illegal input\n");
if(startTime==-1)
{
return 0;
}
}
while(durationTime>0)
{
endTime=startTime+durationTime;
if(dayOfWeek>=1&&dayOfWeek<=5)
{
if(startTime
if(endTime>=startTimeOf8am)
{
duration=startTimeOf8am-startTime;
durationTime-=duration;
startTime=startTimeOf8am;
}
else
{
duration=durationTime;
durationTime=0;
}
cost+=duration*0.25;
}
else if(startTime>=startTimeOf8am&&startTime
if(endTime>=startTimeOf6pm)
{
duration=startTimeOf6pm-startTime;
durationTime-=duration;
startTime=startTimeOf6pm;
}
else
{
duration=durationTime;
durationTime=0;
}
cost+=duration*0.4;
}
else
{
if(endTime>=startTimeOf24pm)
{
duration=startTimeOf24pm-startTime;
durationTime-=duration;
startTime=startTimeOf0am;
dayOfWeek++;
if(dayOfWeek>7) dayOfWeek=1;
}
else
{
duration=durationTime;
durationTime=0;
}
cost+=duration*0.25;
}
}
else if(dayOfWeek==6||dayOfWeek==7)
{
if(endTime>=startTimeOf24pm)
{
duration=startTimeOf24pm-startTime;
durationTime-=duration;
startTime=startTimeOf0am;
dayOfWeek++;
if(dayOfWeek>7) dayOfWeek=1;
}
else
{
duration=durationTime;
durationTime=0;
}
cost+=duration*0.15;
}
}
printf("The cost of the call is:%.2f\n",cost);
}
//system("pause");
return 0;
}
输入 542 12 3 输出4.80
输入 0 1440 1 输出450.00
输入 0 1440 6 输出216.00
输入 0 2880 5 输出666.00
支持跨8点,跨6点,跨天的持续电话时间。追问绝对霸气啊
全部回答
- 1楼网友:琴狂剑也妄
- 2021-01-20 15:06
。。。。。直接要的一个计费软件追问看不懂4.8是怎么算出来的追答看说明,542就是通话开始时间,根据说明这个时间是从夜间12点算,上午9:02就是542,12是通话时长,3是通话日期,根据说明3代表星期三,星期三8:00am到6:00pm的通话费是每分钟0.4,12分钟就是4.8
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯