第40套
填空题
请补充main函数,该函数的功能是:从键盘出入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。
例如,当str1=”abcdefg”时,则str2=”aceg”。
注意:部分源程序给出如下
仅在横线上填入所编写的若干表达式或语句,请勿改动函数中的任何内容。
试题程序:
#include
#include
#define LEN 80
main()
{
char str1[LEN], str2[LEN];
char *p1 = str1, *p2 = str2;
int i = 0, j = 0;
printf("Enter the string:\n");
scanf(___1___);
printf("****** the origial string ********\n");
while (*(p1+j))
{
printf("___2___", *(p1+j));
j++;
}
for (i=0; i
*p2++ = *(str1+i);
*p2 = '\0';
printf("\nThe new string is:%s\n", ___3___);
}
第1处填空:”%s”,str1
第2处填空:%c
第3处填空:str2
编辑特别推荐: