例题:请补充 main函数,该函数的功能是:从键盘输入一个字符串并保存在字符s1中,把字符串s1中下标为奇数的字符保存在字符串s2中并输出。
例如,当s1= “asdfgh”时,则s2= “sfh”。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
代码如下:
#include<stdio.h>
#include<conio.h>
#define N 80
main()
{
char s1[N],s2[N];
char*temp1=s1,*temp2=s2;
int i=0,j=0;
printf("Please Enter the string:");
scanf("%s",s1);
printf("\nThe original string is:");
while(*(temp1+j))
{
printf("%c",*(temp1+j));
j++;
}
for(i=1;i<j;i+=2)
*temp2++=*(s1+i);
*temp2='\0';
printf("\n\nThe new string is:%s\n",s2);
}
输出运行窗口如下:
越努力越幸运!
加油,奥力给!!!