Hello, everyone. I have a question. I have a task in which I have to cin a number (not bigger than 2^32) and the program have to check if it's numbers in hex are equal. I can't use loops. So with the help of mask, I separate the numbers but now I don't know how exactly to compare them all, especially when not all 8 avaliable positions are not occupied... (ex. 1365 in hex is equal to 555, but the number 555 doesn't have 8 digits, so the first 5 are zeros... ). Here is my code:
#include <iostream>
using namespace std;
int main()
{
unsigned long int n;
cin >> n;
int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, k = 0;
int mask = 0xF;
a = n & mask;
n = n >> 4;
b = n & mask;
n = n >> 4;
c = n & mask;
n = n >> 4;
d = n & mask;
n = n >> 4;
e = n & mask;
n = n >> 4;
f = n & mask;
n = n >> 4;
g = n & mask;
n = n >> 4;
h = n & mask;
return 0;
}
if anyone can tell me how to continue... I'll be grateful!