已存在文件file.txt,其内容为sample1234ASDw,请写出程序的运行结果 。 #include <stdio.h> #include <stdlib.h> int main() { FILE *fp; char ch; int count=0; fp = fopen("file.txt", "r" ); if (fp == 0 ) { printf("file error\n" ); exit(1); } ch = fgetc(fp); while(!feof(fp ) ) { if (ch >= 'a' && ch <= 'z') count++; ch="fgetc(fp);" } printf("%d\n", count); fclose(fp ); return 0;>
第2题
函数ReadWrite()的功能是实现从文件in40.dat中读取两个字符串,并调用函数findstr(),最后把结果输出到文件out40.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=%dkn",n);
ReadWrite();
}
ReadWrite()
{
char ch, str[81],substr[3];
int n,len, i=0;
FILE *rf,*wf;
rf=fopen("in40.dat","r");
wf=fopen("out40.dat","w");
while(i<5)
{
fgets(str,80,rf);
fgets(substr,10,rf);
len=strlen(substr)-1;
ch=substr[len];
if(ch=='\n'||ch==Oxla)
substr[len]=0;
n=findStr(str,substr);
fprintf(wf,"%dln",n);
i++;
}
fclose(rf);
fclose(wf);
}
第3题
W: Yeah! It was delivered yesterday. What do you drink of it?
M: It's huge. It practically takes up file entire side of the room.
W: I know. I know, you don't drink it's, well, excessive, do yen?
M: I didn't say that. I metal, if you enjoy it, why not? What happened to your old TV, anyway?
W: It just stopped working last Friday. It was pretty old and didn't work well. I thought you eon afford it. Why not get a new one?
M: It must have been expensive.
W: Well, not as much as you might think. I got it on sale for 50% off.
M: Really? Where?
W: At file stereo city on Route 20. You know at first I just wanted to replace what I had, a TV of about the same size and quality. But the salesman was pushing these because of the 50% off.
M: Yeah. But 50% off what?
W: 2,400 dollars.
M: You spent $ 1,200 on a TV?
W: It's got a lot of special features. Look at this remote control.
M: I'm sure. But that's still a lot of money for a television. I didn't think you watch TV that much.
W: Well, I don't. Do you think I ought to return it? If I do it within a week of purchase, I canget my money back.
M: Honestly, yes. And you know what, I think you ought to mad up on TVs first and choose the make and model you want before you go to the store. That way you will get what you want.
W: I think you are fight.
(20)
A.A popular television program.
B.A breakthrough in technology.
C.A recent purchase.
D.A new electronic store.
第4题
函数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);
}
第7题
A.读和执行
B.读或执行
C.写和执行
D.读和写
第8题
W: Worse, believe it or not.
What does the woman say about the course?
A.It is more difficult than everyone says.
B.It is not interesting at all.
C.She doesn't believe the course is difficult.
D.It is as difficult as everyone says.
第9题
A.Vessel heels until water enters a hatch
B.Vessel in collision floods through a damaged area above the waterline
C.Vessel takes on water due to the hatches being left open in heavy rain
D.Vessel takes on water by the propeller shaft due to failure of the stern gland
第10题
A.put up from
B.put up by
C.put up with
D.put up to
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!