12345678910111213141516171819202122232425 |
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- for (int n; cin >> n; ) {
- if (n == 0) {
- cout << "0-->0" << endl;
- continue;
- }
- cout << n << "-->";
- if (n < 0) {
- n *=- 1;
- cout << '-';
- }
- int m = n, k = 0;
- while (m) {
- k++;
- m /= 2;
- }
- for (int i = k - 1; i >= 0; i--) {
- cout << ((n >> i) & 1);
- }
- cout << endl;
- }
- return 0;
- }
|