字符串str由数字字符‘0’和‘1’组成(长度不超过8个字符),可看作二进制数,请补

题型:填空题

问题:

字符串str由数字字符‘0’和‘1’组成(长度不超过8个字符),可看作二进制数,请补充函数fun(),该函数的功能是:把str字符串转换成十进制数,结果由函数返回。例如,输入“1001”,结果输出:9。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int fun(char *str)

int n;
char *p=str;
【1】 ;
p++;
while (*p)

n= 【2】 ;
p++;

return 【3】 ;
main()

char str[9];
int i;
int n;
printf ("Enter a string made up of ’0’ and
’1’ digital character:");
gets (str);
if (strlen(str)>8)

printf ("Error:string too longer!
please input again !\n\n");
exit(0);

for(i=0;str[i];i++)
if(str[i]<’0’||str[i]>’1’)

printf("Error:%c not is ’0’and
’1’ digital character !\n\n",
str[i]);
exit(0);

printf("The original string:");
puts(str);
n=fun(str);
printf("\n%s is convered to decimal
number:%d\n\n",str,n);

考点:计算机等级考试C语言二级C语言机试
题型:填空题

健康心理学的工作领域不包括( )。

A.疾病防御和治疗中的心理学问题

B.促进健康服务和健康服务政策的制定

C.生活方式及心理活动与疾病的关系

D.心身疾病的诊断和治疗

题型:填空题

环状的线粒体DNA进行复制的方法采用()。

题型:填空题

简述慢性淋巴细胞白血病的临床分期。

题型:填空题

下列哪种消费理论认为居民消费不会随经济的繁荣与衰退而变化()。

A.凯恩斯消费理论

B.生命周期理论

C.持久收入假说

D.相对收入假说

题型:填空题

介绍性演讲的目的不包括()。

A、宣传组织

B、发展合作

C、增进友情

D、开拓新事物

更多题库