问题 多项选择题

改错题(16分)【程序功能】统计一组单词(本题中含2个单词)中的每个单词在一篇文章中各自出现的次数,单词中的字母字符区分大小写。【测试数据与运行结果】测试数据:文章正文: The Olympic Games will be held just outside the capital and the whole area will be called ’Olympic City’.被统计的一组单词:Olympic, will屏幕输出:Olympic:2 wi11:2【含有错误的源程序】以下源程序已保存在T盘myf1.c文件内,考生可直接打开该文件调试程序。1#include< stdio.h>2#include< conio.h>3#include< string.h>4#include< ctype.h>5void count( char str[] ,char substr[][10] ,int ct[],int n)6{7int i,j,k =0,m =0;8char t[];9for(i=0;str[i];i++)10 {11 for(j=i;isalpha(str[j]);i++)12 {13 t[m]=str[j];14 j++;m++;15 }16 t[m]=’/0’;17 for(k=0;k

答案

参考答案:第H行 char t[]; 改为t[A0]第AF行 t[m]=’/0’; 改为’\0’第AH行 if(t== substr[k]) 改为 !strcmp(t,substr[k])或strcmp(t, substr[k] ==0)第BI行 count (line[] ,word[][],c,B); 改为 (line, word,c,B)

单项选择题
单项选择题