你的程序怎么写的?
程序代码:
程序代码:#include<stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
main()
{
char s[33]; /*待转二进制字符串,也是要变为手动键盘输入的部分*/
char *p=s ;
int i, j, n = 0;
gets(s);
j = strlen(s); /*求出二进制位数*/
printf("%d位二进制数\t",j);
puts(s);
for (i = 0;i < j;i++)
{
if(*(p + i) == '1') /*判断某一位是否为'1'*/
{
n=n + pow(2.0,j - 1 - i); /*求相应十进制的值*/
}
}
printf("转为十进制后,值为:%d\n",n);
}







