69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
char *s="1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
int i;
int c;
while((c=getchar())!=EOF)
{
for(i=1;s[i]&&s[i]!=c;i++);
if(s[i]) //此句成立的条件是s[i]存在与*s中吗?
putchar(s[i-1]);
else
putchar(c);
}
return 0;
}
#include <stdio.h>
int main()
{
char *s="1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
int i = 0;
int c;
printf("字符串 S 的内容为:\n");
while(s[i])
{
printf("%c ",s[i]);
i++;
}
printf("\n");
while((c=getchar())!=EOF)
{
for(i=0; s[i] && (s[i] != c); i++);
if(s[i]) //此句成立的条件是s[i]存在与*s中吗?
{
putchar(s[i]);
}
else
{
putchar(c);
}
}
return 0;
}
#include <stdio.h>
int main()
{
char *s="1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
int i = 0;
int c;
printf("字符串 S 的内容为:\n");
while(s[i])
{
printf("%c ",s[i]);
i++;
}
printf("\n");
while((c=getchar())!=EOF)
{
for(i=1; s[i] && (s[i] != c); i++);
if(s[i]) //此句成立的条件是s[i]存在与*s中吗?
{
putchar(s[i-1]);
}
else
{
putchar(c);
}
}
return 0;
}
char *s="1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
这里错了 char *s="1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./"; 少了一个‘\’