Problem Description

珊珊到了美國猶他州的楊百翰大學之後,文文禁不住對她的思念,常常想打電話給她,卻又擔心在美國的她是不是在睡覺。好不容易鼓起勇氣打通了電話,第一句就先問:「妳那裡現在幾點了?」請你幫文文寫一個程式,輸入台灣時間後,算出美國山區時間。 

The Input

輸入僅有一行,其中含有一個整數 h (0 ≤ h ≤ 23),代表台灣時間現在幾點 (24 小時制)。因為美國時間的分與台灣時間的分相同,因此幾分就不用輸入計算了。

The Output

輸出美國山區時間 (24 小時制)。台灣的時間比美國山區時間快 15 小時 (不考慮日光節約時間)。

Sample Input

21

Sample Output

6

-----* Problem from【ZeroJudge, an Online Judge System For Beginners

My Answer

 
1
2
3
4
5
6
7
8
9
10
  #include<iostream>
using namespace std;
int main(void)
{
  int h;
  while(cin>>h){
    (h>=0 &&h <15) ? cout<<h+9<<endl : cout<<h-15<<endl;
  }
  return 0;
}
 

 


arrow
arrow
    全站熱搜

    兔老大 發表在 痞客邦 留言(0) 人氣()