#include<bits/stdc++.h>
using namespace std;
main()
{
long long ts;
cin>>ts;
while(ts--)
{
string s,s1,s3;
char c;
long long i,k=0,k1=0,ar[100]={0},ar1[100]={0},sum=0,sum1=0,ans,pow1=0,k2=0;
cin>>s>>c>>s1;
for(i=s.size()-1;i>=0;i--)
{
if(s[i]>='0'&&s[i]<='9')
{
k=s[i]-48;
sum=sum+k*(pow(16,(pow1))+.0000000000001);
}
else
{
k=s[i]-55;
sum=sum+k*(pow(16,(pow1))+.0000000000001);
}
pow1++;
}
pow1=0;
for(i=s1.size()-1;i>=0;i--)
{
if(s1[i]>='0'&&s1[i]<='9')
{
k=s1[i]-48;
sum1=sum1+k*(pow(16,(pow1))+.0000000000001);
}
else
{
k=s1[i]-55;
sum1=sum1+k*(pow(16,(pow1))+.0000000000001);
}
pow1++;
}
if(c=='+')
{
ans=sum+sum1;
}
else if(c=='-')
{
ans=sum-sum1;
}
while(sum!=0)
{
ar[k2]=sum%2;
sum/=2;
k2++;
}
while(sum1!=0)
{
ar1[k1]=sum1%2;
sum1/=2;
k1++;
}
for(i=0;i<(13-k2);i++)
{
cout<<0;
}
for(i=k2-1;i>=0;i--)
{
cout<<ar[i];
}
printf(" %c ",c);
for(i=0;i<(13-k1);i++)
{
cout<<0;
}
for(i=k1-1;i>=0;i--)
{
cout<<ar1[i];
}
cout<<" = ";
cout<<ans<<endl;
}
}
using namespace std;
main()
{
long long ts;
cin>>ts;
while(ts--)
{
string s,s1,s3;
char c;
long long i,k=0,k1=0,ar[100]={0},ar1[100]={0},sum=0,sum1=0,ans,pow1=0,k2=0;
cin>>s>>c>>s1;
for(i=s.size()-1;i>=0;i--)
{
if(s[i]>='0'&&s[i]<='9')
{
k=s[i]-48;
sum=sum+k*(pow(16,(pow1))+.0000000000001);
}
else
{
k=s[i]-55;
sum=sum+k*(pow(16,(pow1))+.0000000000001);
}
pow1++;
}
pow1=0;
for(i=s1.size()-1;i>=0;i--)
{
if(s1[i]>='0'&&s1[i]<='9')
{
k=s1[i]-48;
sum1=sum1+k*(pow(16,(pow1))+.0000000000001);
}
else
{
k=s1[i]-55;
sum1=sum1+k*(pow(16,(pow1))+.0000000000001);
}
pow1++;
}
if(c=='+')
{
ans=sum+sum1;
}
else if(c=='-')
{
ans=sum-sum1;
}
while(sum!=0)
{
ar[k2]=sum%2;
sum/=2;
k2++;
}
while(sum1!=0)
{
ar1[k1]=sum1%2;
sum1/=2;
k1++;
}
for(i=0;i<(13-k2);i++)
{
cout<<0;
}
for(i=k2-1;i>=0;i--)
{
cout<<ar[i];
}
printf(" %c ",c);
for(i=0;i<(13-k1);i++)
{
cout<<0;
}
for(i=k1-1;i>=0;i--)
{
cout<<ar1[i];
}
cout<<" = ";
cout<<ans<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন