发布网友 发布时间:2022-05-27 16:23
共1个回答
热心网友 时间:2023-11-03 03:11
#include "stdio.h"
int main(int argc,char *argv[]){
char d[33];
int i,t;
printf("Please enter a string composed of '0' and '1'...\n");
if(scanf("%32[01]",d)==1){
for(t=i=0;d[i];(t*=2)+=d[i++]-'0');
printf("%s(2) --> %d(10)\n",d,t);
}
else
printf("Input error, exit...\n");
return 0;
}
代码格式和运行样例图片: