Erick


私信TA

用户名:dotcpp0642224

访问量:187

签 名:

等  级
排  名 18643
经  验 698
参赛次数 0
文章发表 9
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:1.先要讀入字符串,因需要包含可能的空格,故定義字符數組後,不能只用%s讀入

                2.數組讀入後,需要遍歷,查找符合條件的字符,再來調用函數

                3.字符也是整型,故可以使用10進制解題

注意事项:

参考代码:

#include<stdio.h>

#include<string.h>//調用strlen函數,需此頭文件


void fun_0(char *ch);//函數聲明,因要改變變量的值,故需要引入指針


int main(void)

{

char get_0[100];

int len_0;

int i;

scanf("%[^\n]",get_0);//除了\n全部讀入

len_0=strlen(get_0);

for(i=0;i<len_0;i++){

if((get_0[i]>='a'&&get_0[i]<='z')||(get_0[i]>='A'&&get_0[i]<='Z')) {

fun_0(&get_0[i]);

}

printf("%c",get_0[i]);

}

return 0;

}


void fun_0(char *ch){

if((*ch>=97&&*ch<122)||(*ch>=65&&*ch<90)){

*ch+=1;

} else if(*ch==122){

*ch=97;

} else if(*ch==90){

*ch=65;

}

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区