十进制转换为十六进制-反转十六进制值Decimal to Hex - Reversing Hex Value

``````#include <iostream>
#include <array>

using namespace std;

void putInOrder(string *s1, string *s2);
void copy(int *f, int *t, int n);
void reverse(char *x, int n);
int byteSwap(int i);

int main() {

string a = "A";
string z = "Z";
auto *s1 = (string *) "A";
auto *s2 = (string *) "Z";
putInOrder(&z, &a);

int arr1 [3] = {3,4,5};
int arr2 [3] = {6,7,8};
int n;
cout << "Enter a number of values to be copied: ";
cin >> n;
copy(arr1,arr2,n);

char x = 0;
string name = "Computer";
reverse(&name[0],9);

byteSwap(2030);

return 0;
}
void putInOrder(string *s1, string *s2)
{
cout << s1 << " " << s2 << endl;

if(s2 > s1)
{
swap(s1,s2);
}
else if (s1 > s2)
{
cout << s1 << " " << s2 << endl;
}
cout << s1 << " " << s2 << endl;

}

void copy(int *f, int *t, int n)
{

for(int i = 0; i <= n + 2; ++i)
{
t[i+3] = f[i];
cout << t[i] << " ";
}
cout << "\n";
}

void reverse(char *x, int n)
{

for(int i = n - 1; i >=0; --i)
{
cout << x[i] << "";
}
cout << "\n";
}

int byteSwap(int i)
{

}
``````

1 个回复1

===============>>#1 票数：0

``````#include <iostream>
#include <bitset>

int main()
{
std::bitset<16> num(2030);
std::string numstr(num.to_string());

std::string numstrrev;
for (size_t i = 0, n = numstr.size(); i < n; i+=4)
numstrrev = numstr.substr(i, 4) + numstrrev;

std::bitset<16> numrev(numstrrev);

std::cout << std::hex << numrev.to_ulong() << std::endl;

return 0;
}
``````

1回复

1回复

2回复

2回复

3回复

1回复

6回复

1回复

3回复

2回复