2个回答

qq_36519444 求写一下

`````` #include<bits/stdc++.h>
using namespace std;
const int N =105;
double n;
int a[]={10,2,8,16};
void out(int n){
if(n>=0 && n<=9) printf("%c",n+'0');
else printf("%c",n-10+'A');
}
void solve(int num,int x){
if(num<=0) return;
solve(num/x,x);
out(num%x);
}
void solveFloat(double num,int x,int depth){
if(depth>10) return;
double tmp = num*x;
int big = tmp;
double small = tmp-big;
out(big);
solveFloat(small,x,depth+1);

}
void show(double n,int x){
printf("%d representation is: ",x);
if(n<0) printf("-"),n=-n;
int num = n;
solve(num,x);
if(num!=n){
printf(".");
solveFloat(n-num,x,0);
}
puts("");
}
int main() {
while(scanf("%lf",&n)==1){
for(int i=0;i<4;i++){
show(n,a[i]);
}
}
return 0;
}

``````

-14.48
10 representation is: -14.48000000000
2 representation is: -1110.01111010111
8 representation is: -16.36560507534
16 representation is: -E.7AE147AE147
61.3585
10 representation is: 61.35849999999
2 representation is: 111101.01011011110
8 representation is: 75.26743247737
16 representation is: 3D.5BC6A7EF9DB

qq_36519444 额，后面+A+0的也没学过，能不能重新改改？，拜托了

zjck1995 回复qq_36519444: 额，那把那两行删了吧，对这个程序没啥用

qq_36519444 那开头的using和const也没见过学过，怎么换呢？

zjck1995 回复qq_36519444: 指这个<bits/stdc++.h>吗？这个头文件包含所有C/C++标准库,你把这个改成stdio.h一样能运行的，没有区别的

qq_36519444 您好能不能简单点呢，比如开头那部分没见过，能不能变成stdio.h开头这样适合新人的