从键盘输入一个字符串,删除其中的字母a后输出.例如,输入字符串“abcaca”,输出bcc 这是我编写的:

从键盘输入一个字符串,删除其中的字母a后输出.例如,输入字符串“abcaca”,输出bcc 这是我编写的:
#include
main(){
int sr1[20],str2[20]={0};
int i,j;
scanf("%d",&str1);
i=0;
j=0;
while (str1[i]!=''){
while(str1[i!='a']){
str2[j]=str1[i];
printf("%d",str2[j]);
j++;
}
i++;
}
str2[j]='';
}
有一个错误,请大神指导.
zxgdh 1年前 已收到1个回答 举报

Emilyhetcm 幼苗

共回答了20个问题采纳率:95% 举报

/*
123abcoa90bcag
123bco90bcg
*/
#include
int main() {
char s[20];
int i = 0;
scanf("%s",s);
while(s[i]) {
if(s[i] != 'a')
printf("%c",s[i]);
i++;
}
printf("n");
fflush(stdin);
getchar();
return 0;
}

1年前 追问

8

zxgdh 举报

能修改下我的不?大神 #include main(){ int str1[20],str2[20]={0}; int i,j; scanf("%d",&str1); i=0; j=0; while (str1[i]!='') { while(str1[i]!='a'){ str2[j]=str1[i]; printf("%d",str2[j]); j++; } i++; } str2[j]=''; }

举报 Emilyhetcm

str1[]应该是char类型,str2[],j是不需要的。 你仔细看看我发上去的代码,其实就是在你的代码基础上修改得到的。
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.806 s. - webmaster@yulucn.com