c语言的问题 tk166填空

来源:百度知道 编辑:UC知道 时间:2024/07/05 20:46:45
tk166.c程序中,函数fun的功能是:将s所指字符串中下标为偶数的字符删除,s中剩余的字符形成的新串
放在t所指的数组中。
例如,当s所指字符串中的内容为“ABCDEFGHIJK”,
在t所指数组中的内容应是“BDFHJ”。

#include <conio.h>
#include <stdio.h>
#include <string.h>
void fun(char *s, char t[])
{
int i, j, n;
n=strlen(s);
for(i=0, j=0; i<n; i++)
if( ____________ )
{ t[j]=s[i]; j++; }
t[j]= ______ ;
}

main()
{
char s[80], t[80];
clrscr();
printf("\n Please enter string s: ");
scanf("%s", s);
fun(s, t);
printf("\n The result is: %s\n", t);
}

#include <conio.h>
#include <stdio.h>
#include <string.h>
void fun(char *s, char t[])
{
int i, j, n;
n=strlen(s);
for(i=0, j=0; i<n; i++)
if( ______i%2______ )
{ t[j]=s[i]; j++; }
t[j]= __'\0'____ ;
}

main()
{
char s[80], t[80];
clrscr();
printf("\n Please enter string s: ");
scanf("%s", s);
fun(s, t);
printf("\n The result is: %s\n", t);
}