题目详情
当前位置:首页 > 计算机考试 > 中级软件设计师
题目详情:
发布时间:2024-05-23 21:11:51

[简答题]【说明】本程序从正文文件text.in中读入一篇英文短文,统计该短文中不同单词及出现次数,并按词典编辑顺序将单词及出现次数输出到正文文件word.out中。 程序用一棵有序二叉树存储这些单词及其出现的次数,边读入边建立,然后中序遍历该二叉树,将遍历经过的二叉树上的结点的内容输出。 #include <stdio.h> #include <malloc.h> #include <ctype.h> #include <string.h> #define INF "text.in" #define OUTF "wotd.out" typedef struct treenode{ char *word; int count; struct treenode *left,*right; }BNODE int getword (FILE *fpt,char *word) { char c; c=fgetc (fpt); if ( c=EOF) return 0; while(!(tolower(c)>=’a’ && tolower(c)<=’z’)) { c=fgetc (fpt); if ( c==EOF) return 0; } /*跳过单词间的所有非字母字符*/ while (tolower (c)>=’a’ && tolower (c)<=’z’) { *word++=c; c=fgetc (fpt); } *word=’/0’; return 1; } void binary_tree(BNODE **t,char *word) { BNODE *ptr,*p;int compres; P=NULL; (1) ; while (ptr) /*寻找插入位置*/ { compres=strcmp (word, (2) );/*保存当前比较结果*/ if (!compres) { (3) ;return;} else { (

更多"【说明】本程序从正文文件text.in中读入一篇英文短文,统计该短文中"的相关试题:

[简答题]【说明】本程序从正文文件text.in中读入一篇英文短文,统计该短文中不同单词及出现次数,并按词典编辑顺序将单词及出现次数输出到正文文件word.out中。
程序用一棵有序二叉树存储这些单词及其出现的次数,边读入边建立,然后中序遍历该二叉树,将遍历经过的二叉树上的结点的内容输出。
#include <stdio.h>
#include <malloc.h>
#include <ctype.h>
#include <string.h>
#define INF "text.in"
#define OUTF "wotd.out"
typedef struct treenode
char *word;
int count;
struct treenode *left,*right;
BNODE
int getword (FILE *fpt,char *word)
char c;
c=fgetc (fpt);
if ( c=EOF)
return 0;
while(!(tolower(c)>=’a’ && tolower(c)<=’z’))
c=fgetc (fpt);
if ( c==EOF)
return 0;
/*跳过单词间的所有非字母字符*/
while (tolower (c)>=’a’ && tolower (c)<=’z’)
*word++=c;
c=fgetc (fpt);

*word=’/0’;
return 1;

void binary_tree(BNODE **t,char *word)
BNODE *ptr,*p;int compres;
P=NULL; (1)
while (ptr) /*寻找插入位置*/
compres=strcmp (word, (2) <
[简答题]【说明】 以下【C程序】的功能是从文件text_01.ini中读入一篇英文短文,统计该短文中不同单词和它的出现次数,并按词典编辑顺序将单词及它的出现次数输出到文件word_xml.out中。 该C程序采用一棵有序二叉树存储这些单词及其出现的次数,一边读入一边建立。然后中序遍历该二叉树,将遍历经过的二叉树上节点的内容输出。 程序中的外部函数 int getword(FILE *fpt,char *word) 从与fpt所对应的文件中读取单词置入word,并返回1;若已无单词可读,即到文件尾部时,则函数返回0。 【C程序】 #include <stdio.h> #include <malloc.h> #include <ctype.h> #include <string.h> #define INF "TEXT_01.INI" #define OUTF "WORD_XML.OUT" typedef struct treenode { char *word; int count; struct treenode *left, *right; } BNODE; int getword(FILE *fpt,char *word); void binary tree(BNODE **t,char *word) { BNODE *ptr, *p; int cmpres; p = NULL; (1) ; while (ptr) { /*寻找插入位置*/ cmpres = strcmp(word, (2) ); /* 保存当前比较结果*/ if (!cmpres) { (3) return; } else { (4) ; ptr = cmpres > 0 ptr->right : ptr->left; } } ptr = (BNODE *)malloc(sizeof(BNODE)); ptr->right = ptr->left = NULL; ptr->word = (char *)malloc(strlen
[单项选择]INFILE语句用于从外部文件读入数据,必须出现在( )语句之前
A. OUTPUT
B. INPUT
C. INTO
D. END
E. IFTHEN
[单项选择]计算机要运行磁盘上的程序时,应先把程序文件读入到()。
A. 硬盘
B. ROM
C. RAM
D. CPU
[简答题][说明]
以下[C程序]完成从指定数据文件中读入职工的工号和他完成产品个数的数据信息,对同一职工多次完成的产品个数进行累计,最后按表5-22所示的格式输出职工完成产品数量的名次(ORDER)。该名次是按每位职工完成的产品数量(QUANTITY)排序,之后同一名次的职工人数(COUNT)和他们的职工号(NUMBER,同一名次的职工号以从小到大的顺序输出)。

表5-22 职工完成产品数量名次输出格式表

ORDER
QUANTITY
COUNT
NUMBER
1
398
3
10
20
21
[填空题][说明]
本程序实现对指定文件内的单词进行计数。其中使用二叉树结构来保存已经读入的不同单词,并对相同单词出现的次数进行计数。此二叉树的左孩子结点的字符串值小于父结点的字符串值,右孩子结点的字符串值大于父结点的字符串值。函数getword(char *filename,char*word)是从指定的文件中得到单词。char* strdup(char* s)是复制s所指向的字符串,并返回复制字符串的地址。
[函数]
#include <stdio. h>
#include<ctype. h>
#include <string.h>
#define MAXWORD 100
struct node
char *word;
int count;
struct node *left;
struct node *right;

struct node *addtree(struct node *p,char *w)
int cond;
if (p==NULL) /*向树中插入结点*/
p=(struct node*) malloc(sizeof(struct node));
p->word=strdup (w);
p->count=1;
(1) ;

else if((cond=strcmp (w,p->word))==0) (2) ;
else if (cond<0) p->left= (3) ;
else p->right= (4) ;
return p;

main( )
struct node *root;
char word [MAXWORD];
root=NULL;
filename="example .dat";
while getword(filename,word)! =EOF
root= (5) ;


[单项选择]在程序读入字符文件时,能够以该文件作为直接参数的类是( )。
A. FileReader
B. BufferedReader
C. FilelnputStream
D. ObjectlnputStream
[简答题]请完成下列Java程序。程序的功能是复制文件并显示文件,将每个字符读入,并写入另一个文件,同时显示出来。(注意:在本题中,是将D盘的JDK目录下的README.txt文件打印在屏幕上,并写入另一个文件temp.txt中) 注童:请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。 import java.io.*; public class FileCopyBy{ public static void main(String args[]){ try{ FileReader input=new FileReader("FileCopyBy.java"); FileWriter output=new FileWriter("temp.txt"); int c=input.read( ); while(__________) { _______________ System.out.print((char}c); c=input.read( ); } input.close( ); output,close( ); } catch(IOException e) { System.out.println(e); } } }
[简答题]
{{B}}第一节 短文改错{{/B}}
此题要求改正所给短文中的错误。对标有题号的每一行作出判断:如无错误,在该行右边横线上划一个勾(√);如有错误(每行只有一个错误),则按下列情况改正:
多一个词:把多余的词用横线(—)划掉,在该行右边横线上写出该词,并也用斜线划掉。
缺一个词:在缺词处加一个漏字符号(∧),在右边横线上写出该加的词。
错一个词:在错的词下面划一横线,在该行右边的横线上写出改正的词。
注意:原行没有错的不要改。
The best way of learning a language is 76.______
by using it. The best way of learning English
is talking by English as much as possible. 77.______
Sometime you will get your words mixed up 78.______
(混淆) and people will not reach you. 79.______
Sometimes people will say things too quickly
and you can’t understand them. But if you
keep your feeling of humor(幽默) , you can 80.______
always have a good laugh at the mistake you 81.______
make. Don’t be unhappy if people feel like 82.______
to laugh at your mistakes. It is much better
for people to be laugh at your mistake than 83.______
to be angry because they don’t

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
  • 支付完成
  • 取消支付
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码