题目内容

字符串str由数字字符组成(长度不超过5个字符),可看做任意进制的数,请补充函数proc(),该函数的功能是:把str字符串从二进制转换为十进制的数,结果保存在数组xx中,由函数返回转换后数组xx的实际长度。其中x表示str原来的进制,y表示要转换成的进制。例如,输入str="1011", x=2,y=10,结果输出:11。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容。 试题程序: #include<stdio.h> #include<stdlib.h> #include<string.h> #define M 8 int xx[M]; int proc(char*str, int x, int y) int sum; int i=0; char *p=str; for(i=0; i<M; i++) xx[i]=0; sum= (1) ; p++; while(*p) sum=sum*x+*p-’0’; p++; i=0; while(sum!=0) xx[i]= (2) ; (3) ; i++; return i; void main() char str[6]; int i; int n; int x; int y; printf("Enter a string made up of ’0’ to ’9’ digits character: "); gets(str); if(strlen(Str)>5) printf("Error: string too longer!, please input again!\n\n"); exit(0); for(i=0; slr[i]; i++) if(str[i]<’0’||str[i]>’9’) printf("Error: %c not is ’0’to ’9’ digits character! \n\n", str[i]); exit(0); printf("The original string: "); puts(str); printf("\nINPUT x="); scanf("%d", &x); printf("\nINPUT y="); scanf("%d", &y); n=proc(str, X, y); printf("\n%s is convered to", str); for(i=n=1; i>=0; i--) printf("%d\n", xx[i]/n);

查看答案
更多问题

最适合护理目标的方案是

A. 最先进的、效果最佳的
B. 最简单的
C. 最实际、效果最好能被采纳的
D. 最复杂的
E. 以上均不正确

护理评估阶段输出的是

A. 护理计划
B. 护理资料
C. 护理诊断
D. 护理实施
E. 护理评价

课程论解决的主要是怎样编教材的问题。( )

A. 对
B. 错

护理程序的五个步骤错误的是

A. 评估
B. 护理诊断
C. 护理目标
D. 实施
E. 评价

答案查题题库