欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

进制转化

程序员文章站 2022-06-08 11:21:26
...

 

题目:

进制转化

#include <iostream>
using namespace std;


int main()
{
    //方法(1):
    /*int n1;
    int n2;
    int n3;
    int n4;
    cin>>n1>>n2>>n3>>n4;
    
    int A=(n1+n3)/2;
    int C=(n4-n2)/2;
    int B1=(n3-n1)/2;
    int B2=(n2+n4)/2;
    
    if(B1==B2)
    {
        cout<<A<<" "<<B1<<" "<<C<<" "<<endl;
    }
    else
    {
         cout<<"No"<<endl;
    }*/
    
    //方法(2):
    int n1,n2,n3,n4,A,B,C;
    while(cin>>n1>>n2>>n3>>n4)
    {
        A = (n1 + n3) / 2;
        B = (n2 + n4) / 2;
        C = n4 - B;
        if((A -B == n1) && (B-C==n2) && (A+B ==n3) && (B+C ==n4))
            cout<<A<<" "<<B<<" "<<C<<" "<<endl;
        else
            cout<<"No"<<endl;
    }
    
    return 0;
}