@[2345A](/user/565070) 代码我改了改,你看看能不能过
```cpp
#include<bits/stdc++.h>
using namespace std;
void toBinary(long long n) {
if (n == 0) {
cout << "0" << endl;
return;
}
bool isNegative = (n < 0);
n = abs(n);
vector<int> a;
while (n != 0) {
int b = n % 2;
a.push_back(b);
n /= 2;
}
if (isNegative) cout << "-";
for (int i = a.size() - 1; i >= 0; i--) {
cout << a[i];
}
cout << endl;
}
void toOctal(long long n) {
if (n == 0) {
cout << "0" << endl;
return;
}
bool isNegative = (n < 0);
n = abs(n);
vector<int> a;
while (n != 0) {
int o = n % 8;
a.push_back(o);
n /= 8;
}
if (isNegative) cout << "-";
for (int i = a.size() - 1; i >= 0; i--) {
cout << a[i];
}
cout << endl;
}
void toHexadecimal(long long n) {
if (n == 0) {
cout << "0" << endl;
return;
}
bool isNegative = (n < 0);
n = abs(n);
vector<char> a;
while (n != 0) {
int h = n % 16;
char c = (h < 10) ? ('0' + h) : ('A' + h - 10);
a.push_back(c);
n /= 16;
}
if (isNegative) cout << "-";
for (int i = a.size() - 1; i >= 0; i--) {
cout << a[i];
}
cout << endl;
}
int main() {
long long n;
cin >> n;
toBinary(n);
toOctal(n);
toHexadecimal(n);
return 0;
}
```
by qwertyuiop951357 @ 2024-04-14 18:52:56
@[qwertyuiop951357](/user/991301) 过了,谢谢
by 2345A @ 2024-04-14 18:54:41