#include <iostream>
using namespace std;
int main(){
char letter,letter1;
cin>>letter;
char change_to_lower(letter);
char change_to_upper(letter);
char swap(letter);
return 0;
}
char change_to_lower(char a){
if(a=='a'&& a<='z'){
char b= toupper(a);
return b;
}
}
char change_to_upper(char a){
if(a=='A'&& a<='Z'){
char b = tolower(a);
return b;
}
}
char swap(char a){
char letter1,letter2;
a=change_to_lower(letter1);
char b=change_to_upper(letter1);
char temp = a;
a=b;
b=temp;
cout<< a<<" "<< b<<endl;
return b;
}
答案 0 :(得分:0)
您的意思是将字符串中的所有大写字符转换为小写字母,将小写字母转换为大写字母吗?
void swapuplo(char *s)
{
size_t i;
for (i = 0; s[i]; ++i)
if (isupper(s[i]))
s[i] = tolower(s[i]);
else if (islower(s[i]))
s[i] = toupper(s[i]);
}
这是调用例程
int main()
{
char buf[] = "HeLLo WORLD";
swapuplo(buf);
printf("%s\n", buf);
getchar();
return 0;
}
输出:
hEllO world
请务必包含<ctype.h>
,其中包含字符测试功能的声明。