2006年9月计算机等级考试三级网络上机试题

2006年9月计算机等级考试三级网络上机试题,第1张

2006年9月计算机等级考试三级网络上机试题,第2张

南开问题19:
写一个函数findstr(),统计一个长度为2的子串在另一个字符串中出现的次数。例如,假设输入字符串为“asd asasdfg asd as zx67 asd mklo”,子串为“as”,函数返回值为6。
read write dat()的作用是从文件in.dat中读取两个字符到4,调用函数findstr(),最后将结果输出到文件out.dat
注意:已经给出了部分源程序。
请不要更改main函数()和ReadWrite()的内容。
-
int findstr(char * str,char * substr)
{
/*请参考南开100问*。

南开问题2:整数排序问题

# include
# define MAX 200
int a[MAX],b[MAX],CNT = 0;
void jsVal()
{ int i,j,qw,bw,sw,GW;
for(I = 0;I { qw = a[I]/1000;bw=a[i]/100;
sw=a[i]0/10;gw=a[i];
if(qw & & qw % 2 = = 0 & & bw % 2 = = 0 & & SW % 2 = = 0 & & GW % 2 = = 0)b[cnt++]= a[I];
}
for(I = 0;I for(j = I+1;j if(b[I]}
void read dat()
{
int I;
FILE * FP;
fp = fopen("in.dat "," r ");
for(I = 0;i < MAXi++) fscanf(fp,“%d”,& a[I]);
f close(FP);
}
void main()
{
int I;
read dat();
jsVal();
printf("满足条件的数字=%d\n ",CNT);
for(I = 0;i < cnti++) printf("%d ",b[I]);
printf(" \ n ");
write dat();
}
write dat()
{
FILE * FP;
int I;
fp = fopen("out.dat "," w ");
fprintf(fp," %d\n ",CNT);
for(I = 0;i < cnti++) fprintf(fp," %d\n ",b[I]);
f close(FP);
}

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 2006年9月计算机等级考试三级网络上机试题

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情