进制转化
程序员文章站
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;
}