top) { printf("Pop an empty stack!/n"); return -1;} return (3) ; } void MultibaseOutput(long n, int B) { int m; Stack S; if (InitStack(&S, MAXSIZE)) {printf("Failure!/n"); return;} do { if (Push(&S, (4) )) {printf("Failure!/n"); return;} n = (5) ; }while(n != 0); while(!StackEmpty(S)) { /* 输出B 进制的数 */ m = Pop(&S); if(m < 10) printf("%d", m); /* 小于10,输出数字 */ else printf("%c", m + 55); /* 大于或等于10,输出相应的字符 */ } printf("/n"); }">

试题四 阅读以下说明和C 代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 [说明] 函数MultibaseOutput(long n, int B)的功能是:将一个无符号十进制整数n 转换成B(2≤B≤16)进制数并输出。该函数先将转换过程中得到的各位数字入栈,转换结束后再把B 进制数从栈中输出。有关栈操作的诸函数功能见相应函数中的注释。C 代码中的符号常量及栈的类型定义如下: #define MAXSIZE 32 typedef struct { int *elem; /* 栈的存储区 */ int max; /* 栈的容量,即栈中最多能存放的元素个数 */ int top; /* 栈顶指针 */ }Stack; [C 代码] int InitStack(Stack *S, int n) /* 创建容量为n 的空栈 */ { S->elem = (int *)malloc(n * sizeof(int)); if(S->elem == NULL) return -1; S->max = n; (1) = 0 ; return 0; } int Push(Stack *S, int item) /* 将整数item 压入栈顶 */ { if(S->top == S->max){ printf("Stack is full!/n"); return -1;} (2) = item ; return 0; } int StackEmpty(Stack S) { return (!S.top) 1 : 0; } /* 判断栈是否为空 */ int Pop(Stack *S) /* 栈顶元素出栈 */ { if(!S->top) { printf("Pop an empty stack!/n"); return -1;} return (3) ; } void MultibaseOutput(long n, int B) { int m; Stack S; if (InitStack(&S, MAXSIZE)) {printf("Failure!/n"); return;} do { if (Push(&S, (4) )) {printf("Failure!/n"); return;} n = (5) ; }while(n != 0); while(!StackEmpty(S)) { /* 输出B 进制的数 */ m = Pop(&S); if(m < 10) printf("%d", m); /* 小于10,输出数字 */ else printf("%c", m + 55); /* 大于或等于10,输出相应的字符 */ } printf("/n"); }

题库:初级程序员 类型:简答题 时间:2017-07-03 12:09:58 免费下载:《问答集》Word试卷

试题四 阅读以下说明和C 代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 [说明] 函数MultibaseOutput(long n, int B)的功能是:将一个无符号十进制整数n 转换成B(2≤B≤16)进制数并输出。该函数先将转换过程中得到的各位数字入栈,转换结束后再把B 进制数从栈中输出。有关栈操作的诸函数功能见相应函数中的注释。C 代码中的符号常量及栈的类型定义如下: #define MAXSIZE 32 typedef struct { int *elem; /* 栈的存储区 */ int max; /* 栈的容量,即栈中最多能存放的元素个数 */ int top; /* 栈顶指针 */ }Stack; [C 代码] int InitStack(Stack *S, int n) /* 创建容量为n 的空栈 */ { S->elem = (int *)malloc(n * sizeof(int)); if(S->elem == NULL) return -1; S->max = n; (1) = 0 ; return 0; } int Push(Stack *S, int item) /* 将整数item 压入栈顶 */ { if(S->top == S->max){ printf("Stack is full!/n"); return -1;} (2) = item ; return 0; } int StackEmpty(Stack S) { return (!S.top) 1 : 0; } /* 判断栈是否为空 */ int Pop(Stack *S) /* 栈顶元素出栈 */ { if(!S->top) { printf("Pop an empty stack!/n"); return -1;} return (3) ; } void MultibaseOutput(long n, int B) { int m; Stack S; if (InitStack(&S, MAXSIZE)) {printf("Failure!/n"); return;} do { if (Push(&S, (4) )) {printf("Failure!/n"); return;} n = (5) ; }while(n != 0); while(!StackEmpty(S)) { /* 输出B 进制的数 */ m = Pop(&S); if(m < 10) printf("%d", m); /* 小于10,输出数字 */ else printf("%c", m + 55); /* 大于或等于10,输出相应的字符 */ } printf("/n"); }

试题四
    阅读以下说明和C 代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
[说明]
    函数MultibaseOutput(long

本题关键词:说明,处方药说明书,说明书,非处方药说明书,工程说明,错误说明,警示说明,说明义务,免疫应答反应,免疫应答;

微信扫码获取答案解析
下载APP查看答案解析