请补充函数fun(),该函数的功能是:把字符下标能铍2或3整除的字符从字符串str中删除,把剩余的字符重新保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdefghijk”,输出“bfh”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[], int n){int i, k;【 】;for(i=0; i<n; i++){s[k++]=s[i];if(【 】)k--;}【 】;}main(){int i=0,strlen=0;char str[N];clrscr();printf("\nInput a string:\n");gets(str);while(str[i]!='\0'){strlen++;i++;}fun(str,strlen);printf('\n*** display string ***\n");puts(str);}

请补充函数fun(),该函数的功能是:把字符下标能铍2或3整除的字符从字符串str中删除,把剩余的字符重新保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。

例如,输入“abcdefghijk”,输出“bfh”。

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。

试题程序:

include <stdio.h>

define N 80

void fun(char s[], int n)

{

int i, k;

【 】;

for(i=0; i<n; i++)

{

s[k++]=s[i];

if(【 】)

k--;

}

【 】;

}

main()

{

int i=0,strlen=0;

char str[N];

clrscr();

printf("\nInput a string:\n");

gets(str);

while(str[i]!='\0')

{

strlen++;

i++;

}

fun(str,strlen);

printf('\n*** display string ***\n");

puts(str);

}


相关考题:

以下函数 fun 的功能是返回 str 所指字符串中以形参 c 中字符开头的后续字符串的首地址 , 例如 : st r所指字符串为 : Hello! , c 中的字符为 e ,则函数返回字符串 : ello! 的首地址。若 str 所指字符串为空串或不包含 c 中的字符,则函数返回 NULL 。请填空。char *fun(char *str,char c){ int n=0; char *p=str;if(p!=NULL)while(p[n]!=cp[n]!='\0') n++;if(p[n]=='\0') return NULL;return( 【 1 2 】 );}

请编写一个函数void fun(cbara [], charb [], int n),其功能是:删除一个字符申中指定下标的字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,n中存放指定的下标。例如,输入一个字符串world,然后输入3,则调用该函数后的结果为word。注意:部分源程序给出如下。请勿改动主函数main 和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>include <conio.h>define LEN 20void fun (char a[], char b [], int n){}main (){char str1 [LEN], str2 [LEN];int n ;clrscr ();printf ("Enter the string : \n") ;gets (str1) ;printf ("Enter the position of the stringdeleted: ");scanf ("%d", n) ;fun (str1, str2, n) ;printf ("The new string is : %s \n",str2) ;}

请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdefghijkl”,输出“cdfhl”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[],int n){int i, j, k, flag;【 】;for(i=0; i<n; i++){if (i>1)s [k++] =s [i];flag=I;for(【 】; j<iflag; j++)if (i%j==0){flag=0;【 】}}s [k]='\0';}main(){int i=0, strlen=0;char str[N];clrscr ();printf("\n Input a string:\n");gets (str);while (str [i] !='\0'){strlen++;i++;}fun (str, strlen);printf("\n*** display string ***\n");puts (str);}

请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“bdf”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[],int n){int i, j;j=0;for(i=0;【 】;i++){if(【 】)s [j++]-s [i];}【 】;}main ( ){int i=0, strlen=0;char str [N];clrscr ();printf ("\nInput a string: \n");gets (str);while (str [i] !='\0'){strlen++;i++;}fun(str, strlen);printf("\n*** display string ***\n");puts (str);}

请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>define LEN 80main(){char str1[LEN],str2 [LEN];char *p1=str1,*p2=str2;int i=0,j=0;clrscr();printf("Enter the string:\n");scanf(【 】);printf("***the origial string***\n");while(*(p1+j)){printf("【 】",*(p1+j));j++;}for(i=0;i<j;i+=2)*p2++=*(str1+i);*p2='\0';printf("\nThe new string is:%s\n", 【 】 );}

以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符串的首地址,例如,str所指字符串为Hello!,c中的字符为e,则函数返回字符串ello!的首地址。若str所指字符串为空或不包含c中的字符,则函数返回NULL,请填空。char *fun(char *str,char c){ int n=0; char *p=str; if(p!=NULL) while(p[n]!=cp[n]!=’\0’) n++; if(p[n]==’\0’) return NULL; return();}

请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“ace”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:inc lude< stdio, h>define N 80【 】{int i, j;【 】for (i=0;i<n;i++){if (s [i] %2!=0)s [j++]=s [i];}【 】;}main ( ){int i=0, strlen=0;char str[N];clrscr ();printf ("\nInput a string:\n");gets (str);while (str [i] !=' \0' ){strlen++;i++;}fun (str, strlen);printf("\n*** display string ***\n");puts (str);}

请补充fun()函数,该函数的功能是:把字符的ASCII码中为奇数的字符从字符串str中删除,结果仍然保存在字符串str中,字符串str从键盘输人,其长度作为参数传人fun()函数。例如,输入“abcdef”,则输出“bdf”。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在mare()函数的横线上填入所编写的若干表达式或语句。试题程序:

请补充函数proc(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。例如,str1=”I am a”,str2=”student”,结果输出:I am a student。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。试题程序: