题目 大写变小写,小写变大写 补充程序Ccon032.C,该程序的功能是将输入的一行字符串的大写字母转变为相应的小写字母,小写字母则转变为相应的大写字母,其余字符不变。 相关知识点: 试题来源: 解析答案: #include void main() { char s[80]; int i;...
{ 【1】 ch[80];inti; printf("请输入一个字符串:"); gets(【2】);for(i=0;ch[i]!='【3】';i++) {if(ch[i]>='A'【4】ch[i]<='Z') ch[i]=ch[i]+32; } printf("转换后的字符串为:\n"); 【5】(ch); } #include <stdio.h>main() {charch[80];inti; printf("请输入一...
1 打开Dev-C++程序。2 写好头函数#include<stdio.h>#include<ctype.h>#include<string.h> 3 写好主函数 4 在a数组中输入一串字符串,将其大写转小写,小写转大写并且存放在b数组中char a[100];char b[100];int i=0,j=0;gets(a);while(a[i]!='\0') { if(a[i]>='A'...
a=a+32;printf("%c",a);} }
输入字符串,判断字符是大写还是小写,大写字符加32,小写字符减32,然后输出即可。
广告 C语言将字符串中的所有小写字母转换为大写字母并输出。 str1[i]-=32; } main() { char str1[80]="This Is a c Program"; clrscr(); printf("String is: %s\n",str1); fun(str1); printf("Result is: %s\n&quo... C语言将字符串中的所有小写字母转换为大写字母并输出。 查看字符串...
总结一下,无论字符串中包含什么字符,capitalize()只对字母有效,首位是字母就大写,非首位是字母就小写。 2.字符串内置函数lower() lower() 将所有字母变成小写字母,同capitalize() 方法只对字母有效; newstr = string.lower()同样生成新字符串(再次加深印象,字符串是不可修改数据类型); ...
在函数内部进行转换:将第一个字符转换为大写(如果它是小写字母),并将剩余的所有字符转换为小写(如果它们是大写字母)。 在主函数中调用该函数:并打印转换后的字符串。 下面是具体的代码实现: c #include <stdio.h> #include <ctype.h> // 函数声明 void convertCase(char *str); int main(...
/*字符串中大写字母变成小写,其余字符不变*/ #include <stdio.h> #include <string.h> char* mystrlwr(char *s) { char *scopy = s; while (*s) { if (*s >= 'A' && *s <= 'Z') { *s = *s + 'a' - 'A'; } s++; } return scopy; } char *mysed_strlwr(char *s) { cha...
转换后 : SINcosTANcot Press any key to continue / include <stdio.h> char *Translate(char s[]) { int i = 0;for(i = 0; s[i]; ++i) { if((s[i] >= 'a') && (s[i] <= 'z')) s[i] += 'A' - 'a';else if((s[i] >= 'A') && (s[i] <= 'Z'))...