永发信息网

从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。

答案:1  悬赏:20  手机版
解决时间 2021-03-26 02:21
  • 提问者网友:你挡着我发光了
  • 2021-03-25 22:38
从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。
最佳答案
  • 五星知识达人网友:英雄的欲望
  • 2021-03-25 22:44
#include
#include#define LEN 80
int main()
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
printf("Enter the string:\n");
scanf("%s",str1);
printf("***the origial string***\n");
while(*(p1+j))
{
printf("%c",*(p1+j));
j++;
}
for(i=0;(i%2==0 && i *p2++=*(str1+i);
*p2='\0';
printf("\nThe new string is:%s\n",str2);
system("pause");
} 注意,你必须按照我的程序来!因为你给出的程序有不少错误!我举一个例子—— for(i=0;i%2==0 && i
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯