根據上網時間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;
}