阅读以下说明和C语言程序,将应填入(n)处的字句写在对应栏内。
【说明】
以字符流形式读入一个文件,从文件中检索出6种C语言的关键字,并统计、输出每种关键字在文件中出现的次数。本程序中规定:单词是一个以空格或'\t'、'\n'结束的字符串。其中6种关键字在程序中已经给出。
【程序】
include <stdio.h>
include <stdlib.h>
FILE *cp;
char fname[20], buf[100];
int NUM;
struct key
{ char word[10];
int count;
}keyword[]={ "if", 0, "char", 0, "int", 0,
"else", 0, "while", 0, "return", 0};
char *getword (FILE *fp)
{ int i=0;
char c;
while((c=getc(fp))!= EOF &&(1));
if(c==EOF)
return (NULL);
else
buf[i++]=c;
while((c=fgetc(fp))!=EOF && c!="&& c!='\t' && c!='\n' )
buf[i++]=c;
buf[i]='\0';
return(buf);
}
void lookup(char *p)
{ int i;
char *q, *s;
for(i=0; i<NUM; i++)
{ q=(2);
s=p;
while(*s && (*s==*q))
{ (3))
if((4))
{ keyword[i].count++;
break;
}
}
return;
}
void main()
{ int i;
char *word;
printf("lnput file name:");
scanf("%s", fname);
if((cp=fopen(fname, "r"))==NULL)
{ printf("File open error: %s\n", fname);
exit(0);
}
NUM=sizeof(keyword)/sizeof(struct key);
while((5))
lookup(word);
fclose(cp);
for(i=0;i<NUM;i++)
printf("keyword:%-20s count=%d\n",keyword[i].word,keyword[i].count);
}
第1题:
阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。
【说明】
以下程序的功能是:从键盘上输入一个字符串,把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来。
【程序】
include < stdio. h >
main( )
{ FILE * fp;
char str[100]; int i=0;
if((fp=fopen("text.txt"(1))) ==NULL)
{ printf("can't open this file. \n") ;exit(0) ;}
printf(" input astring: \n" ); gest(str);
while( str[i] )
{ if(str[i] >='a' && str[i] <='z')
str[i]=(2);
fputc(str[i],(3));
i++;
}
fclose(fp);
fp=fopen(" test.txt",(4));
fgets(str, 100, fp);
printf("%s\n" ,str);
(5);
}
第2题:
阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
完成以下中序线索化二叉树的算法。
[函数]
Typedef int datatype;
Typedef struct node {
Int ltag, rtag;
Datatype data;
*lchild,* rchild;
}bithptr;
bithptr pre;
void inthread ( p );
{if
{inthread ( p->lchild );
if ( p->lchild==unll ) (1);
if ( P->RCHILD=NULL) p->rtag=1;
if (2)
{if (3) pre->rchild=p;
if ( p->1tag==1 )(4);
}
INTHREAD ( P->RCHILD );
(5);
}
}
第3题:
阅读下列说明和流程图,将应填入(n)的字句写在对应栏内。
【说明】
下列流程图(如图4所示)用泰勒(Taylor)展开式
sinx=x-x3/3!+x5/5!-x7/7!+…+(-1)n×x2n+1/(2n+1)!+…
【流程图】

计算并打印sinx的近似值。其中用ε(>0)表示误差要求。
第4题:
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
【说明】
给定函数fun的功能是:将从键盘上输入的每个单词的第一个字母转换为大写字母,输入时各单词必须用空格隔开,用“.”结束输入。
【函数】
int fun(char *c,int status)
{
if((1)=='')
return 1;
else
{
if((2)&&(3)&&(4))
(5)='A'-'a';
return 0;
}
}
main()
{
int flag=1;
char ch;
printf("请输入一字符串,用点号结束输入!\n");
do {
ch=getchar();
flag=fun(&ch,flag);
putchar(ch);
}while(ch!='.');
printf("\n");
}
第5题:
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
【程序2.1说明】
求所有满足如下条件的三位数:它除以11得的商等于它各位数字的平方和。例如 550,除以11商为50,50=52+52+02。
【程序2.1】
void main()
{
int i, j,n,s;
for(i=100;i<=999;i++)
{
n=i;
j=n/11;
s=0;
while((1))
{
(2)
n/=10;
}
if((3))
printf("%d\t",i);
}
}
【程序2.2说明】
本程序输入一字符串,将其中的大写字母改变成小写字母。
【程序2.2】
void main()
{
int i=0;
char s[120];
scanf("%s",s);
while((4))
{
if((5))
s[i]=s[i]- 'A'+'a';
i++;
}
printf("%s\n",s);
}
第6题:
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。
【说明】
阅读下面几段C++程序回答相应问题。
比较下面两段程序的优缺点。
①for (i=0; i<N; i++ )
{
if (condition)
//DoSomething
…
else
//DoOtherthing
…
}
②if (condition) {
for (i =0; i<N; i++ )
//DoSomething
}else {
for (i=0; i <N; i++ )
//DoOtherthing
…
}
第7题:
阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。
[说明]
下面的流程图用于计算一个英文句子中最长单词的长度(即单词中字母个数)MAX。假设该英文句子中只含字母、空格和句点“.”,其中句点表示结尾,空格之间连续的字母串称为单词。
[流程图]

第8题:
●试题二
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
该程序运行后,输出下面的数字金字塔

【程序】
include<stdio.h>
main ()
{char max,next;
int i;
for(max=′1′;max<=′9′;max++)
{for(i=1;i<=20- (1) ;++i)
printf(" ");
for(next= (2) ;next<= (3) ;next++)
printf("%c",next);
for(next= (4) ;next>= (5) ;next--)
printf("%c",next);
printf("\n");
}
}
第9题:
图2-1是基于软交换的网络分层模型。请将选项应填入(n)处的字句写在答题纸对应的解答栏内。

第10题:
()阅读下列说明和C语言程序,将应填入 (n)处的语句写在答题纸的对应栏内。[说明]下面程序是一个带参数的主函数,其功能是显示在命令行中输入的文本文件内容。[C语言函数]#include"stdio.h"main(argc,argv) int argc; char *argv[]; { (1) ; if((fp=fopen(argv[1],”r’’))== (2) ) { printf(”file not open!\n”);exit(0);} while( (3) ) putchar( (4) ); (5); }
第11题:
第12题:

第13题:
阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
以下程序为求行列式X(5,5)的值S。
【Visual Basic代码】
Private Function col ( byval x ( 5,5 ) as integer ) as long
dim fesult as long
dim temp as long
dim I as integer
dim j as integer
dim k as imeger
result = 0
for I = to 5
(1)
for j = 1 to 5
if I+j>6 then
k= ( 1+j ) mod 5
else
k=1
endif
temp=temp*x ( k,j )
(2)
result=(3)
(4)
(5)
End function
第14题:
阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。
[说明]
设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。

第15题:
阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。
[说明] 以下函数完成求表达式

的值,请填空使之完成此功能。
float sum ( float x )
{ float s=0.0;
int sign = 1;
(1);
for(inti=1;(2); i+ +)
{
t=t*x;
s=s+(3);
sign = - sign;
(4);
}
第16题:
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
【说明】
编写程序,生成一个新文本文件,它由一个已知文本文件的所有偶数行组成。要求已知文本文件名和新文本文件名均从键盘输入。请填空完善程序。
【C语言程序】
include<stdio.h>
main()
{
FILE *oldf,*newf;
char ch,fname[20];
int i;
do{
printf("Enter name of existed text file to be read:");
scanf("%s",fname);
if((oldf=fopen(fname,"r"))==NULL)
printf("File %s can't open!\n",fname);
}while(oldf==NULL);
do{
printf("Enter mane of new text file to be written:");
scanf("%s",fname);
if(((1)==NULL)
printf("File %s can't open!\n",fname);
}while((2));
i=1;
while(!feof(oldf))
{
while((ch=fgetc(oldf))!=(3))
{
if(i%2==(4))
fputc(ch,newf);
}
fputc('\n',newf);
(5);
}
fclose(oldf);
fclose(newf);
}
第17题:
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。
【说明】
下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。
import java.io.*;
public class testThrows{
public static (1) readString() (2) IOException{
int ch;
String r="";
boolean done=false;
while((3)){
ch=System.in.read();
if(ch<0 || ch=0xd) //处理回车符中第一个符号
done=true;
else
r=r+(char)ch;
}
return r;
}
public static void main(Stling args[]){
String str;
(4) {
str=readString();
} (5) (IOException e){
System.out.println("error");
return;
}
System.out.println("input integer: "+Integer.parselnt(str));
}
}
第18题:
阅读下列程序说明和C程序,将应填入(n)处的字句写在对应栏内。
[函数2.1说明]
下面程序的功能是计算x和y的最小公倍数。
[函数2.1]
main()
{ int m,n,d,r;
seanf("%d %d",&m,&n);
if(m<n) {r=m;m=n;n=r;}
(1);
while (d%n! =0) (2);
printf("%d\n",d);
}
[函数2.2说明]
下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。
[函数2.2]
include <stdio.h>
main()
{ char c,preChar='\0';
c = getchar();
while(c! = '.'){
if((3)) putchar(c);
else if(preChar! =' ') putchar(c);
(4);
c=(5);
}
}
第19题:
阅读下列说明和流程图,将应填入(n)处的语句写在对应栏内。
【说明】
设学生(学生数少于50人)某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图用于读取该文件,并把全部成绩从高到低排序到数组B[50]中。
【流程图】

第20题:
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

第21题:
(a)智能网概念模型中分布功能平面模型如下图所示,请根据此图将应填入(n)处的 字句写在答题纸的对应栏内。

第22题:
图6-1是下一代网络的体系结构简图,请根据此简图将应填入(n)处的字句写在答题纸的对应栏内。

第23题:
第24题:

