prog19.c

来自「c题库」· C语言 代码 · 共 34 行

C
34
字号
/*
编写函数fun,该函数的功能是:从字符串中删除指定的字符。同一字母的大、小写按不同字符处理。
  例如:若程序执行时输入字符串为: turbo c and borland c++  从键盘上输入字符n,则输出后变为:turbo ca ad borald c++
  如果输入的字符在字符串中不存在,则字符串照原样输出。
  注意:部分源程序给出如下。
  请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
*/

#include <stdio.h>
#include <conio.h>
int fun(char s[],int c)
{


}

main()
{	static char str[]="turbo c and borland c++";
	char ch;
	clrscr();
	printf(" :%s\n",str);
	printf(" :");
	scanf("%c",&ch);
	fun(str,ch);
	printf("str[]=%s\n",str);
}

/*
答案:
	int i,k=0;
	for(i=0;s[i];i++)
		if(s[i]!=c) s[k++]=s[i]; 
	s[k]='\0';
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?