返回列表 發帖
#include<iostream>
#include<cstdilb>
using namespace std;
int main()
{
    int age
    re:
    cout<<"請輸入你的年齡:";
    cin>>age;
    if(age>=0&&age<=3)
    {
        cout<<"購買幼兒票(免費入場)"<<endl;
    }
    else if(age>=4&&age<=12)
    {
         cout<<"購買兒童票(50元)"<<endl;
    }
    else if(age>=13&&age<=64)
    {
         cout<<"購買一般票(100元)"<<endl;
    }
    else if(age>=&&age<=65)
    {
         cout<<"購買敬老票(70元)"<<endl;
    }
    else
        cout<<"別鬧了"<<endl;
    goto re:
    system("pause");

TOP

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{  
    re:
    int x, y, smaller, sum=0;
    cout<<"請輸入第一個數: ";
    cin>>x;
    cout<<"請輸入第二個數: ";
    cin>>y;
    smaller=x<y?x:y;
    cout<<x<<"與"<<y<<"的公因數有: ";
    for(int i=1; i<=smaller; i++)
    {
        if(x%i==0 && y%i==0)
        {
            cout<<i<<" ";
            sum++;
        }
    }
    cout<<endl<<"共有"<<sum<<"個!"<<endl<<endl;
    goto re;
    return 0;   
}

TOP

返回列表