当前位置:首页 > Visual FoxPro
2013年计算机二级考试VFP上机精选题及答案15
假定输入的字符中只包含字母和*号。请编写函数fun,它的功能是:除了字符串前导的*号之外,将串中其他*号全部删除,。在编写函数时,不得使用c语言提供的字符串函数。
例如,若字符串中的内容为****A*BC*DEF*G*******,删除后,字符串中的内容则应当是****ABCDEFG。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
#include
#include
#include
void fun(char *a)
{
}
main()
{
char s[81]; 来源:考试大网
FILE *out;
printf("Enter a string :\n");
gets(s);
fun( s );
printf("The string after deleted:\n");
puts(s);
out=fopen ("out.dat", "w");
strcpy(s, "****A*BC*DEF*G*******");
fun(s);
fprintf(out, "%s", s);
fclose (out );
}
参考答案:
1、应改为for(i=1;i<=3;i++)
2、应改为if(k>=0&&k<=6)