Files
python/GESP/Level4/GESP202306/Test2.cpp

26 lines
483 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
// 十进制转十六进制
string toHex(int x) {
string res;
while (x) {
int t = x % 16;
if (t >= 10)
res += t - 10 + 'A';
else
res += t + '0';
x /= 16;
}
reverse(res.begin(), res.end());
if (res.empty())
return "00";
if (res.size() == 1)
return "0" + res;
return res;
}
int main() {
for (int x = 0; x <= 255; x++)
cout << toHex(x) << endl;
return 0;
}