c语言 编写程序,将用户输入的字符串中所有的字符a用*代替,然后输出

作者&投稿:屠瑾 (若有异议请与网页底部的电邮联系)
编写程序,将用户输入的字符串中所有的字符a用*代替,然后输出。~

main(){
int i;
char s[128];
gets(s);
i=0;
while(s[i]){
if (s[i]=='a') s[i]='*';
i++;
}
printf("%s
",s);
}

#include
int Fib (int n);//函数声明
void main ()
{
int i,n;
printf ("input the n: ");
scanf ("%d",&n);
printf ("斐波契数列的前%d项为:
",n);//输入项数
for (i=0;i<=n;i++)
printf ("%d ",Fib (i));
printf ("
");
}
int Fib (int n)
{
if (n==0||n==1)
return 1;
return Fib(n-2)+Fib(n-1);
}

#include <stdio.h>
#include <string.h>
void main(){
int i,n;
char str[100];
gets(str);
n=strlen(str);
for(i=0;i<n;i++)
if(str[i]=='a') str[i]='*';
str[n]='\0';
printf("%s",str);
}


# include <stdio.h>
void main()
{ char c[80];
int i;
gets(c);
for(i=0;i<80;i++)
if(c[i]=='a') c[i]='*';
puts(c);
}


前进区15660714389: 用C语言编写:接受用户从键盘输入的两个字符,然后输出他们的代码 -
定南羚黄: #include<stdio.h>main(){ char c[2] ; int i = 0;for(i=0;i<2;i++){printf("请输入第%d个字符\n",i+1);scanf("%c",c[i])}for(i=0;i<2;i++){printf("请输入第%d个字符:%c\n",i+1,c[i]);}}大致是这样 , 好久没用C了

前进区15660714389: c语言 编写程序,将用户输入的字符串中所有的字符a用*代替,然后输出 -
定南羚黄: # include <stdio.h> void main() { char c[80]; int i; gets(c); for(i=0;i<80;i++) if(c[i]=='a') c[i]='*'; puts(c); }

前进区15660714389: 用c语言编写一个程序,接受用户输入字符串;编写一个函数,讲用户的指定字符删除,再输出字符串. -
定南羚黄: # include # define N 20 int main(void) { char ch[N], find; int i; printf("请输入字符串:"); scanf("%s", ch); printf("请输入你要查找的字符:"); scanf("%c", &find); for(i=0; i { if (ch[i] != find) putchar(ch[i]); } return 0; }

前进区15660714389: 编写一个C程序,实现由用户输入一个字符,程序输出它的ASCⅡ码值 C程序的高手帮帮忙 谢谢了 -
定南羚黄: else if((a+b>=c)&&(a+c>=b)&&(b+c>=a)) return true; 这就已经返回退出程序了怎么会有答案输出呢 只有当 if(a<=0||b<=0||c<=0) cout<<"Error! 请输入正数.";成立时才有输出你的程序有问题 #include<iostream> using namespace std; #...

前进区15660714389: 用C语言编写程序:接收用户输入的字符串,并以相反的顺序输出该字符串 -
定南羚黄: #include #include int main() { char input[1024]; int len, i; printf("Input string...\n"); gets(input); len = strlen(input); for (i = len-1; i>=0; i--) { printf("%c", input[i]); } printf("\n"); getch(); return 0; }

前进区15660714389: C语言:编写一个程序,接受一个用户输入的一行字符,按回车结束 -
定南羚黄: int main() {char str[100],*p;int cout[4]={0};scanf("%[^\n]",&str);p=str;while(*p){if((*p>='A'&&*p<='Z')||(*p>='a'&&*p<='z'))cout[0]++;else if(*p==' ')cout[1]++;else if(*p>='0'&&*p<='9')cout[2]++;elsecout[3]++;p++;}printf("\nletter=%d,...

前进区15660714389: c语言中要求用户自己输入的语句怎么写 -
定南羚黄: 一般可以用scanf(),因为可以用来输入各种格式的数据. 比如有int类型的变量a,char类型的b,可以用 scanf("%d",a); scanf("%c",b);

前进区15660714389: C语言中编程实现:从键盘键入一个大写字母,立即回显出其小写字母 -
定南羚黄: #include <stdio.h>#include <ctype.h> void main() {char buffer[] = "a 19-YEAR-OLD SAYS HE'S READY TO MAKE A DIFFERENCE.";int i = 0;scanf("%s", &buffer);while(buffer[i] != '\0'){if(isupper(buffer[i]))printf("%c", buffer[i] + 32);...

前进区15660714389: 编写一个程序,完成将用户输入的任意一个小写字母转换成大写字母 -
定南羚黄: #include"stdio.h" void main() {char c,a; printf("Please input a Lowercase letter !\n"); c=getchar(); a=c-32; printf("The Capital letter is %c",a); getchar(); getchar(); }

前进区15660714389: 编写c语言程序,要求用户输入一个字符串,程序将字符串字母反序输出.即如果输入为abcd,则输出为dcba. -
定南羚黄: #include<stdio.h> #include<string.h> int main() { char str[20],c; int i,n; printf("str="); gets(str); n=strlen(str); for(i=0;i<n/2;i++) { c=str[i]; str[i]=str[n-i-1]; str[n-i-1]=c; } puts(str); return 0; }

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网