UVA839 - Not so Mobile

题目较为简单,不做多余解释,递归函数的简单应用

代码如下:

#include <iostream>

using namespace std;
int cacult(int &qual)
{
    int w1, d1, w2, d2, temp;
    if(cin>>w1>>d1>>w2>>d2 == 0)return -1;
    if(!w1)
        w1 = cacult(temp);
    if(!w2)
        w2 = cacult(temp);
    if(w1*d1 == w2*d2&&temp)qual = 1;
    else qual = 0;
    return w1+w2;
}
int main ()
{
    int temp, n;
    cin>>n;
    while(n--)
    {
        if(cacult(temp) == -1)break;
        if(temp)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        if(n)cout<<endl;
    }
    return 0;
}


posted on 2012-11-08 21:20  Primo...  阅读(122)  评论(0)    收藏  举报