第5题
可以实现从键盘输入一个作为双精度变量a的值的语句是
A.a=InputBox()
B.a=InputBox(“请输入一个值”)
C.a=Val(InputBox(“请输入一个值”))
D.a=Val(InputBox() )
第6题
A.a=InputBox()
B.a=InputBox(“请输入一个值”)
C.a=Val(InputBox(“请输入一个值”))
D.a=Val(IaputBox())
第9题
编写一个函数findStr(char*str,char*substr),该函数统计一个长度为2的子字符串substr在另一个字符串str中出现的次数,该次数作为函数值返回。例如,假定输入的字符串为”asd asasdfg asd as zx67 asdmklo”,子字符串为”as”,函数返回值是6。 函数ReadWrite实现从文件in.dat中读取两个字符串,并调用函数findStr,最后把结果输出到文件out.dat中。 注意:部分源程序存在test.c文件中。请勿改动主函数main和其他函数中的任何内容,仅在函数findStr的花括号中 填入你编写的若干语句。
第10题
编写一个函数findStr(),该函数统计一个长度为2的子字符串在另一个字符串中出现的次数。例如,假定输入的字符串为"asd asasdfg asd as zx67 asd mklo",子字符串为"as",函数返回值是6。
函数ReadWrite()实现从文件in.dat中读取两个字符串并调用函数findStr(),最后把结果输出到文件out.dat中。
注意:部分程序已经给出。
请勿改动主函数main()和其他函数中的任何内容,仅在函数findStr()的花括号中填入你编写的若干语句。
include <stdio.h>
include <string.h>
include <conio.h>
int findStr(char *str,char *substr)
{
}
main()
{
char str[81],substr[3];
int n;
clrscr();
printf("输入原字符串");
gets(str) ;
printf("输入子字符串:");
gets(substr);
puts(str);
puts(substr);
n=findStr(str, substr);
printf("n=%d\n", n);
ReadWrite();
}
ReadWrite()
{
char str[81],substr[3],ch;
int n, len,i=0;
FILE *rf, *wf;
rf=fopen("in.dat", "r");
wf=fopen("out.dat", "w");
while(i<25)
{
fgets(str, 80, rf);
fgets(substr, 10, rf);
len=strlen(substr)-1;
ch=substr[len];
if(ch=='\n' || ch==0xla)substr[len]=0;
n=findStr(str, substr);
fprintf(wf, "%dkn", n);
i++;
}
fclose(rf);
fclose(wf);
}
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!