回顾大一·C语言编程3.4(1)

来源:互联网 发布:域名信息隐藏 编辑:程序博客网 时间:2024/05/04 12:10

根据上网时间t计算并输出上网费用cost,计算公式:

 

同时为了鼓励多上网,每月收费最多不超过300元。


#include<stdio.h>
int main()
{
int t,cost;
printf("上网费用cost=");
scanf("%d",&t);
if(t<10)
cost=30;
else if(t>=50&&t<=120)
cost=2.5*t;
else if(t>=10&&t<50) 
cost=2.5*t;
else if(t>120)
putchar('\a');
printf("%d\n",cost);
return 0;
}