![](https://static.youtibao.com/asksite/comm/h5/images/m_q_title.png)
规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函 数时,
![规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函 数时,](https://img2.soutiyun.com/ask/uploadfile/11262001-11265000/73238fff0abf62af6cc0127851b7cf47.jpg)
![规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函 数时,](https://img2.soutiyun.com/ask/uploadfile/11262001-11265000/9bd8f294467ae55057a1fd450a7b289d.jpg)
![](https://static.youtibao.com/asksite/comm/h5/images/solist_ts.png)
例如,若字符串中的内容为****A*BC*DEF*G******,删除后,字符串中的内容应当是ABCDEFG******。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio. h>
void fun(char *a, char *p)
{
}
main ()
char s[81],*t;
printf ("Enter a string: \n ");
gets (s);
t=s;
while (*t)
t++;
t--; /*指针t指向字符串尾部* /
while (*t== '*' )
t--; /*指针t指向最后一个字母*/
fun (s, t);
printf ("The string after deleted: \n");
puts (s);
}
注意:部分源程序在文件PROCl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填人你编写的若干语句。
例如,字符串中的内容为****A*BC*DEF*G*******,若 n的值为2,删除后,字符串中的内容则应当是 **A*BC*DEF*G*******;若n的值为4,则字符串中的内容仍为****A*BC*DEF*G******。n的值在主函数中输入。在编写函数时,不得使用C语言提供的字符串函数。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include <conio.h>
void fun (char Aa, int n)
{
}
main ()
{ char s[81];int n;
printf ("Enter a string : \n") ;gets (s);
printf ("Enter n : "); scanf ("%d", &n);
fun(s,n );
printf("The string after deleted :\n");
puts (s);
}
例如,分别输人下面两个字符串:FirstString——SecondString
程序运行后的输出结果是:FirstString————SecondString
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
例如,若输入“aboaEf9”,则应输出“aBe4EF9”。
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
例如,若字符串中的内容为****A*BC*DEF*G*******,删除后,字符串中的内容则应当是A*BC*DEF*G。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include <conio.h>
void fun (char *a;int n ,int h ,int e)
{
}
main ()
{
char s [81],*t,*f;
int m=0,tn=0, fn=0;
printf("Enter a string :\n");
gets (s);
t=f=s;
while (*t)
{t++;m++; } /*m为字符串的长度*/
t--; /*指针t指身字符串尾部*/
while (*t=='*')
{t--; tn++; }
/*指针t指向最后一个字母,tn统计尾部'*'的个数*/
while (*f=='*' )
{f++;fn++;}
/*指针f指向第一个字母,tn统计导'*'的个数*/
fun(s, m, fn, tn);
printf ("The string after deleted: \n");
puts (s);
}
例如:程序执行时输入字符串为turbo c and borland c++,从键盘上输入字符n,则输出后变为turbo c ad borlad c++。
如果输入的字符在字符串中不存在,则字符串照原样输出。
注意:部分源程序已存在文件test18_2.cpp中。
请勿改动主函数脚in和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test18_2.cpp的内容如下:
include<stdio.h>
include<iostream.h>
include<conio.h>
void fun(char s[ ], int c)
{
}
void main ()
{
static char str[ ]="turbo c and borland c++";
char ch;
cout<<"原始字符串:\n"<<str<<end1;
cout<<"输入一个字符:";
cin>>ch;
fun(str.ch);
cout<<"str="<<str<<end1;
}
例如:原来的字符串为CEAedca,则排序后输出为CedcEAa。
注意:部分源程序已存在文件test22_2.cpp中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test22_2.cpp的内容如下:
include <iostream.h>
include <stdio.h>
include <ctype.h>
include <conio.h>
void int fun(char *s, int num)
{
}
void main ()
{
char s[10];
printf ("输入7个字符的字符串:");
gets(s);
fun(s,7);
cout<<s;
}