2 条题解
-
0
Guest
-
1
- 二进制
#include<bits/stdc++.h> using namespace std; int main(){ stack<int> st; int n; cin>>n; while(n){ st.push(n%2); n/=2; } while(!st.empty()){ cout<<st.top(); st.pop(); } return 0; }
- 八进制
#include<bits/stdc++.h> using namespace std; int main(){ stack<int> st; int n; cin>>n; while(n){ st.push(n%8); n/=8; } while(!st.empty()){ cout<<st.top(); st.pop(); } return 0; }
- 十六进制
#include<bits/stdc++.h> using namespace std; int main(){ stack<int> st; int n; cin>>n; while(n){ st.push(n%16); n/=16; } while(!st.empty()){ if(st.top()>=10){ cout<<char(st.top()-10+'A'); } else{ cout<<st.top(); } st.pop(); } return 0; }
信息
- ID
- 269
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 22
- 已通过
- 20
- 上传者