import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
StringBuilder sb = new StringBuilder("");
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++) {
String[] str=br.readLine().split(" ");
int x=Integer.parseInt(str[0], 16);
int y=Integer.parseInt(str[2], 16);
int result;
if("+".equals(str[1])){
result=x+y;
}else{
result=x-y;
}
StringBuilder tempX=new StringBuilder(Integer.toBinaryString(x));
StringBuilder tempY=new StringBuilder(Integer.toBinaryString(y));
while(tempX.length()<13){
tempX.insert(0, '0');
}
while(tempY.length()<13){
tempY.insert(0, '0');
}
sb.append(tempX).append(" ").append(str[1]).append(" ")
.append(tempY).append(" = ").append(result).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment