更多"规定输入的字符串中只包含字母和*号。请编写函数fun,其功能是:将字符"的相关试题:
[多项选择]规定输入的字符串中只包含字母和*号。请编写函数fun,其功能是:将字符串尾部的*号全部删除,前面和中间的*号不动。
注意:部分源程序给出如下。
请勿改动主函数mam和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include <stdio.h>
#include <conio.h>
void fun (char *a)
void main( )
char s[81];
printf("Enter a string:/n");
gets(s);
fun(s);
printf("The string after deleted:/n");
puts(s);
[简答题]规定输入的字符串中只包含字母和*号。请编写函数fun,其功能是:使字符串中尾部的*号不多于n个,若多于n个,则删除多余的*号;若少于或等于n个,则不做任何操作,字符串中间和前面的*号不删除。
例如,字符串中的内容为“****A*BC*DEF*G*******”,若n的值为4,删除后,字符串中的内容应为“****A*BC*DEF*G****”;若n的值为7,则字符串中的内容仍为“****A*BC*DEF*G*******”。n的值在主函数中输入。编写函数时,不得使用C语言提供的字符串函数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
void fun(char*a,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);
[简答题]规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:除了字符串前导和尾部的*号外,将串中其他的*号全部删除。形参h已指向字符串中第一个字母,形参P指向字符串中最后一个字母。在编写函数时,不得使用C语言提供的字符串函数。
例如,若字符串中的内容为“****A*BC*DEF*G*******”,删除后,字符串中的内容应当是“*****ABCDEFG********”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void fun(char*a,char*h,char*p)
main( )
char s[81],*t,*f;
printf("Enter a string:/n");
gets(s);
t=f=s;
while(*t)
t++;
t--;
while(*t==’*’)
t--;
while(*f==’*’)
f++;fun(s,f,t);
printf("The string after deleted:/n");
puts(s);
[简答题]假定输入的字符串中只包含字母和*号。请编写函数fun,其功能是:除了尾部的*号之外,将字符中其他的*号全部删除。形参P已指向字符串中最后的一个字母。在编写函数时,不得使用C语言提供的字符串函数。
例如,字符串中的内容为“****A*B*DEF*
G********”,删除后,字符串中的内容应当是“ABCDEFG*******”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#incIude<conio.h>
#include<sfdio.h>
void fun(char*a,char*P)
void 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);
[简答题]规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函数时,不得使用C语言提供的字符串函数。
例如,字符串中的内容为“****A*BC*DEF*G*******”,删除后,字符串中的内容应当是“ABCDEFG”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
void fun(char*a)
voidmain( )
char s[81];
printf("Enter a string:/n");
gets(s);
fun(s);
printf("The string after delete&/n");
puts(s);
[简答题]规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:将字符串中的前导*号全部删除,中间和尾部的*号不删除。
例如,字符串中的内容为“*******A*BC*DEF*G****”,删除后,字符串中的内容应当是“A*BC*DEF*G****”。编写函数时,不得使用C语言提供的字符串函数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<conio.h>
void fun(char*a)
void main( )
char s[81];
printf("Enter a string:/n");
gets(s);
fun(s);
printf("The string after deleted:/n");
puts(s);
[简答题]假定输入的字符串中只包含字母和*号。请编写函数 fun( ),它的功能是:只删除字符串前导和尾部的*号,串中字母之间的*号都不删除。形参n给出了字符串的K度,形参h给出了字符串中前导*号的个数,形参e给出了字符山中最后*号的个数。在编写函数时,不得使用c语言提供的字符串函数。
例如,若字符串中的内容为****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);
[简答题]假定输入的字符串中只包含字母和*号。请编写函数 fun( ),它的功能是:使字符串中前部的*号不得多余n个;若多余n个,则删除多余的*号;若少于或等于n个,则什么也不做,字符串中间和尾部的*号不删除。
例如,字符串中的内容为****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);
}
[简答题]假定输入的字符串中只包含字母和*号。请编写函数 fun( ),它的功能是:除了尾部的,:号之外,将字符串中其他*号全部删除。形参p已指向字符串中最后一个字母。在编写函数时,不得使用C语言的字符串函数。
例如,若字符串中的内容为****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);
}
[简答题]请编写函数fun( ),其功能是:将s所指字符串中除了下标为奇数、同时ASCII值为偶数的字符外,其余的全部删除,串中剩余字符所形成的一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为edB2A4Dsdg,其中字符A的ASCII码值为奇数,因此应当删除;其中字符B的ASCII码值为偶数,但在数组中的下标为偶数,因此也应当删除:而字符2的ASCII码值为偶数,所在数组中的下标为奇数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是d24。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
#include<string, h>
void fun(char*s, char t[])
{
}
main( )
{
char s[100] ,t[100];
clrscr( );
printf("/nPlease enter string S: ");
scanf("%s",s);
fun(s,t);
printf("/nThe result is: %s/n",t);
}