December 31, 2010

c程式語言 停車場費率

題目是 停車的時間若小於等於5分鐘,就不算時間
           停車的時間若大於5分鐘然後又小於等於60分鐘,就算兩個半小時
           停車的時間若大於60分鐘,前兩個半小時之後,用百分之30來計算,但如果過了一小時又過小於等於五分鐘,這五分鐘不算錢
           
           星期一~星期五 一個半小時算15元
           星期六~星期日 是平日的兩倍            

 

#include
#include

int main(void)

{
 int t,t1,t2,h,h1,h2,w,f;

 printf("請輸入停車時間:");
 scanf("%d",&t);

 printf("請輸入星期(1~7):");
 scanf("%d",&w);

 if (t<=5) h=0;

 if ((t>5) && (t<=60)) h=2;


 if (t>60)
 {
    h1=2;

  t1=t-60;

  t2=t1%30;

  h2=t1/30;

  if (t2>5)  h2=h2+1;


  h=h1+h2;
 }

 if((w>=1) &&(w<=5)) f=h*15;
 else f=h*15*2;

 printf("停車時間:%d分,停車費用共計:%d元\n",t,f);
 system("pause");
 return 0;
}

0推薦此文章
Today's Visitors: 0 Total Visitors: 35
Personal Category: c語言程式 Topic: learning / education / linguistic
Previous in This Category: c語言程式 二次 三次 四次方的計算   Next in This Category: c語言程式 國英數成績平均的計算
[Trackback URL]

Post A Comment









Yes No



Please input the magic number:

( Prevent the annoy garbage messages )
( What if you cannot see the numbers? )
Please input the magic number

誰來收藏
Loading ...
unlog_NVPO 0