題目是http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=18212

同時也是第53次ITSA的題目

無條件進入的用法是

要打上#include <math.h>

double num=1.736;

int p=ceil(num);

這樣p就會變成2

只要照著題目的意思寫程式碼,並在迴圈裡執行,當進入的人數>洞裡的人時就break

這題就完成了

  1. #include<iostream>  
  2. #include <math.h>  
  3. using namespace std;  
  4. int main()  
  5. {  
  6.     int num;  
  7.     cin>>num;  
  8.     for(int i=0;i<num;i++)  
  9.     {  
  10.         double first;  
  11.         int enter;  
  12.         cin>>first>>enter;  
  13.         while(1)  
  14.         {  
  15.             int go=ceil(first*3/4);  
  16.             first-=go;  
  17.             if(first<enter)  
  18.                 break;  
  19.             first+=enter;  
  20.         }  
  21.         cout<<first<<endl;  
  22.     }  
  23. }  

 

若想閱讀相關文章請關注我的粉絲團

小資菜鳥向前衝

https://www.facebook.com/%E5%B0%8F%E8%B3%87%E8%8F%9C%E9%B3%A5%E5%90%91%E5%89%8D%E8%A1%9D-204484273323335/?fref=ts

arrow
arrow
    文章標籤
    程式設計 題目介紹
    全站熱搜

    cychss6305 發表在 痞客邦 留言(0) 人氣()