int i,j;printf("input srtring a:");gets(a);for(i=0;a[i];i++) //复制到数组b b[i]=a[i];b[i]='\0';for(i=0;b[i];i++) //将数组b中所有小写字母改为大写字母 if('a'<=b[i]&&b[i]<='z') b[i]-=32;j=i;for(i=0;a[i];i++) //将a中字符...
char b[200];printf("输入字符串:");gets(a);fun(a,b);printf("元音:%s\n",b);return 0;}
只要扫描整个字符串,将找到的'a'换为'b'即可。然后输出整个字符串。include<stdio.h> int main(){char s[200];int i;gets(s); //获取字符串 for(i=0;s[i];i++) //扫描串 if(s[i]=='a') //若符合要求 s[i]++; //将'a'换为'b'puts(s); //输出整个字符...
include<stdlib.h> include<string.h> define MAX 10 int main(){ char n; //输入字符个数 char ch[MAX] ; //存放输入的字符 char b[MAX]; //存放ch中的小写字符 for (int i = 0; i < strlen(ch); i++){ scanf("%c",&n);ch[i] = n;if (ch[i] >= 'a' && ch...
#include\x0d\x0a#include\x0d\x0a#include\x0d\x0a#define MAX 10\x0d\x0aint main(){\x0d\x0a\x0d\x0achar n; //输入字符个数\x0d\x0achar ch[MAX] ; //存放输入的字符\x0d\x0achar b[MAX]; //存放ch中的小写字符\x0d\x0afor (int i = 0; i < strlen(ch...
include<stdio.h> include<string.h> void main(){ char a[100]="",b[100]="";int i=0;int j=0;gets(a);while(a[i]!='\0'){ if(a[i]>='a'&&a[i]<='z'){ b[j++]=a[i];} i++ ;} puts(b);} strcpy的结果每次都把a的值拷贝到b里,结果是b和a一样或b是空...
int main(){ char n; //输入字符个数 char ch[MAX] ; //存放输入的字符 char b[MAX]; //存放ch中的小写字符 for (int i = 0; i < strlen(ch); i++){ scanf("%c",&n);ch[i] = n;if (ch[i] >= 'a' && ch[i] <= 'z' ){ b[i] = ch[i];} } for (int...
题目 (数组 难)从键盘输入一个字符串a,并在a串中的最大元素后边插入字符串b(b[]=“ab”)。试编程。 相关知识点: 试题来源: 解析#include #include main() { char a[80], b[] = “ab”, max; int i = 1, j; printf(“Input a string\n”);...
include <stdio.h> int main(int argc, char const *argv[]){char buf[256] = {0};char *p = NULL;int num = 0;scanf("%s",buf);p = buf;while(*p){if (*p == 'a'){*p = 'b';num ++;}p ++;}printf("the a num:%d string:%s\n",num,buf);return 0;} ...
scanf("%s", &a);n=strlen(a);for(i=0, j=0; i<n; i++){ if(a[i]>='a' && a[i]<='z'){ b[j++]=a[i];} } b[j]=0;printf("%s\r\n", b);