[图] 请给出上面空格处应填入的代码。(请注意,由于答案...
请给出上面空格处应填入的代码。(请注意,由于答案精确匹配,请用半角英文字符作答,不要有非必要的空格)
请给出上面空格处应填入的代码。(请注意,由于答案精确匹配,请用半角英文字符作答,不要有非必要的空格)
第4题
阅读以下说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
从文件IN.DAT中读取一篇英文文章存入到字符串数组XX中;请编写程序,其功能是:以行为单位把字符串中所有小写字母o左边的字符串内容移到该串的右边存放,然后把小写字母o删除,余下的字符串内容移到已处理字符串的左边存放。最后把已处理的字符串仍按行重新存入字符串数组XX中,最后调用函数WRITEDAT(),把结果XX输出到文件OUT5.DAT中。
例如:原文:You can create an index on any field.
you have the correct record.
结果:n any field.Yu can create an index
rd.yu have the crrect rec
原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。
【函数】
#include "stdio.h"
#include "string.h"
#include "conio.h"
#include "ctype.h"
#include "mem.h"
unsigned char xx[50][80];
int maxline=0;
int readdat(void);
void writedat(void);
/*将题目要求的字符串中所有小写字母o左边的字符串内容移到该串的右边存放,即
将串中"最后"一个字母o左右两侧的内容互换*/
void StrOR(void)
{
inti;
char*p1,*p2,t[80];
for(i=0;i<maxline;i++)
{ t[0]=′/0′;
p2=xx[i];
while(*p2)/*找到最后一个′o′*/
{if( (1) )p1=p2;
p2++;
}
strcat(t,p1+1);
*p1=′\\0′;
strcat(t,xx[i]);
p1=xx[i];
p2=t;
while(*p2)/*删去字符′o′*/
{if( (2) ) (3) =*p2;
p2++;
}
(4) ;
}
}
void main()
{
clrscr();
if(readdat())
{printf("Can't open the file IN.DAT!\\n");
return;
}
StrOR();
writedat();
}
int readdat(void)
{
FILE*fp;
int i=0;
char*p;
if((fp=fopen("in.dat","r"))==NULL)
return 1;
while(fgets(xx[i],80,fp)!=NULL)
{p=strchr(xx[i],′\\n′);
if(p)
*p=0;
i++;
}
maxline= (5) ;
fclose(fp);
return 0;
}
void writedat(void)
{FILE*fp;
int i;
fp=fopen("in.dat","w");
for(i=0;i<maxline;i++)
{printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);
}
fclose(fp);
}
}
}
第5题
A.在编辑窗口直接输入一个半角空格
B.代码中输入“ ;”
C.在编辑窗口输入两个全角空格
D.在编辑窗口输入两次空格
第6题
【说明】
从文件IN.DAT中读取一篇英文文章存入到字符串数组XX中;请编写程序,其功能是:以行为单位把字符串中所有小写字母。左边的字符串内容移到该串的右边存放,然后把小写字母。删除,余下的字符串内容移到已处理字符串的左边存放。最后把已处理的字符串仍按行重新存入字符串数组XX中,最后调用函数WRITEDAT(),把结果XX输出到文件 OUT5.DAT中。
例如:原文:You can create an index on any field.
you have the correct record.
结果:n any field.Yu can create an index
rd. yu have the crreet res
原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。
【函数】
include "stdio.h"
include "string.h"
include "conio.h"
include "ctype.h"
include "mem.h"
unsigned char xx[50] [80]
int maxline=0;
int readdat(void);
void writedat(void)
/*将题目要求的字符串中所有小写字母o左边的字符串内容移到谊串的右边存放,即将串中“最后”一个字母o左右两侧的内容互换*/
void StrOR(void)
{
inti;
char*p1,* p2,t[80];
for(i=0;i<maxline;i++)
{ t[0]='/0';
p2=xx[i];
while(*p2) /*找到最后一个别'o'*/
{ if((1))p1=p2;
p2++;
}
strcat(t,p1+1);
*p1='\0';
strcat(t,xx[i]);
p1=xx[i];
p2=t;
while(*p2) /*删去字符'o'*/
{ if((2)) (3)=*p2;
p2++;
}
(4);
}
}
void main()
{
clrscr();
if(readdat())
{ printf("Can't open the file IN. DAT!\n");
return;
}
StrOR();
writedat();
}
int readdat(void)
{
FILE * fp;
int i=0;
char * p;
if((fp=fopen("in.dat","r" ))==NULL)
return 1;
while(fgets(xx[i],80, fp)!=NULL)
{ p=strchr(xx[i],'\n');
if(p)
*p=0;
i++;
}
maxline:(5);
fclose(fp);
return 0;
}
void writedat (void)
{ FILE * fp;
int i;
fp=fopen("in.dat',"w");
for(i=0;i<maxline;i++)
{ printf("%s\n",xx[i]);
fprintf(fp," %s\n",xx[i]);
}
fclose(fp);
}
}
}
第7题
阅读以下说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
该程序的功能是从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中,以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组xx中,最后把结果xx输出到文件OUT6.DAT中。
例如:原文:You He Me
I am a student.
结果:Me He You
student 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*pl,*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);
}
第8题
【说明】
该程序的功能是从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中,以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组xx中,最后把结果xx输出到文件OUT6.DAT中。
例如:原文:You He Me
I am a student.
结果:Me He You
student 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)
}
第9题
程序功能如下:
①单击“读数据”按钮,则将考生文件夹下in5.dat文件的内容(该文件中含有不超过800个英文单词,单词之问用1个空格隔开)显示在Textl文本框中;
②单击“统计”按钮,则自动统计Textl中所有5字母单词的个数,并显示在右下角的Labell标签中。“读数据”按钮的Click事件过程已经给出,“统计”按钮的Click事件过程不完整,函数GetWords的功能是从字符串s中分离出每个单词,依次放入数组words的数组元素中,返回值为单词的总数目。
要求:请将程序中的注释符去掉,把?改为正确的内容;补全“统计”按钮Click事件过程中的代码,以实现上述程序功能。
注意:考生不得修改窗体文件中已经存在的控件和程序,在结束程序运行之前,必须进行“统计”,且必须用窗体右上角的关闭按钮结束程序,否则无成绩。最后,程序按原文件名存盘。
第10题
已知状态机转移图如下:请在空白处补充合适的代码: module reduce (clk, reset, in, out); input clk, reset, in; output out; parameter S0 = 2’b00; parameter S1 = 2’b01; parameter S2 = 2’b10; reg out; reg [1:0] state; reg [1:0] next_state; …… …… always @(in or state) case (state) …… …… S2: begin if (in) begin next_state = S2 ; ; (答案不留空格) end else …… end …… ……
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!