返回列表 發帖
本帖最後由 洪榮辰 於 2024-6-8 14:43 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int age;
  7.     re:
  8.     cout<<"請輸入你的年齡:";
  9.     cin>>age;
  10.     if(age<3 && age>0){
  11.         cout<<"購買幼兒票(免費入場)!"<<endl;
  12.     }
  13.     else if(age>=4 && age<=12){
  14.         cout<<"購買兒童票(50元)!"<<endl;
  15.     }
  16.     else if(age>=13 && age<=64){
  17.         cout<<"購買一般票(100元)!"<<endl;
  18.     }
  19.     else if(age>=65 && age<=100){
  20.         cout<<"購買敬老票(70元)!"<<endl;
  21.     }
  22.     else{
  23.         cout<<"別鬧了!"<<endl;
  24.     }
  25.     goto re;
  26.     system("pause");
  27.     return 0;
  28. }
複製代碼

TOP

返回列表