未分类题

阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。
[函数2.1说明]
下面程序的功能是:将由键盘输入的某个十进制数转换成对应的R进制数并输出。这里R是 2到16的整数,由键盘输入。例如,输入n=128,base=13后的输出为9B。
[函数2.1]
include <stdio.h>
main()
{ char b[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int c[64],n,i=0,base;
printf('Enter a number:');scaaf('%d',&n);
printf('Enter new base:');scanf('%d',&base);
do{c[i]=(1);
i++;
n=n/base;
}while((2));
printf('Transmit new base:');
for(- -i;i>=0;- -i)printf('%c',(3));
}
[函数2.2说明]
所谓回文字符中是指正序和逆序拼写相同的字符串,例如astrtsa,adgdtdgda等。下面函数int fun(char *str)的功能是判断字符串str是否是回文,当字符串是回文时,函数返回1,否则返回0。
[函数2.2]
int fun(char *str)
{ int i,j,l;
for(i=0;str[i]! ='/0';i++);
l=i/2;
for(j=0,i- -;j<=1;(4))
if((5)) return 0;
return 1;
}

A.1说明]
B.1]
include
C.h>
main()
{
D.2说明]
E.2]
int

【参考答案】

(1) n% base (2) n! =0 (3) b[c[i]] (4) j++ i-- (5) str[i]! =s......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题

未分类题
阅读以下说明和C代码,将应填入(n)处的字句写在对应栏内。【说明】该程序的功能是从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中,以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组xx中,最后把结果xx输出到文件OUT6.DAT中。例如:原文:You He MeI am a student.结果:Me He Youstudent a am I原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。【函数】include<string.h>include<conio.h>include<ctype.h>include<stdio.h>char xx[50] [80];int maxline=0; *文章的总行数* int ReaaDat(void);void WriteDat(void);void StrOL(void){char * p1, * p2,t[80];int i;for(i=0;i<maxline;i++){ p1=xx[i];t[0]=0;while(*p1)p1++;while(p1>=xx[i]){ while(!isalpha(*p1) &&p1!=xx[i])p1--;p2=p1;while((1))p1--;if(p1==xx[i])if(isalpha(*p1))p1--;else if(!isalpha(*(p1+1)))break;p2++;(2);strcat(t, p1+1);strcat(t,' ');}strcpy(xx[i],t);}}void main( ){if((3)) {printf('数据文件in.dat不能打开! n 007' );return;}StroL();writeDat();getch();} int ReadDat(void){FILE * fp;int i =0;char * p;if((fp=fopen('e: a in.dat',' r' ))==NULL)return 1;while(fgets(xx[i],80,fp)!=NULL) {p=strchr(xx[i],' n')if(p)*p=0;i++;}maxline=(4)fclose(fp);return 0;}void WriteDat(void){FILE * fp;int i;fp=fopen('e: a out6,dat','w');for(i=0;i<(5);i++){printf('%s n',xx[i]);fprintf(fp,'%s n',xx[i])}fclose(fp)}