蓝桥杯 大小写转换

islower/isupper函数

islower和issupper是C++标准库中的字符分类函数,用于检查一个字符是否为小写字母或大写字母

需要头文件< cctype>,也可用万能头包含

函数的返回值为bool类型

cpp 复制代码
char ch1='A';
char ch2='b';
//使用islower函数判断字符是否为小写字母
if(islower(ch1)){
	cout<<ch1<<"is a lowercase letter."<<endl;
}else{
	cout<<ch1<<"is not a lowercase letter."<<endl;
}
//使用isupper函数判断字符是否为大写字母
if(isupper(ch2)){
	cout<<ch2<<"is an uppercasse letter."<<endl;
}else{
	cout<<ch2<<"is not an uppercase letter."<<endl;
}

tolower/toupper函数

tolower(char ch)可以将ch转换为小写字母,如果ch不是大写字母则不进行操作。

toupper()同理

cpp 复制代码
char ch1='A';
char ch2='b';
//使用tolower函数将字符转换为小写字母
char lowercaseCh1 = tolower(ch1);
cout<<"Lowercase of"<<ch1<<"is"<<lowercaseCh1<<endl;
//使用toupper函数将字符转换为大写字母
char uppercaseCh2=toupper(ch2);
cout<<"Uppercase of"<<ch2<<"is"<<uppercaseCh2<<endl; 

ascill码


相关推荐
春风解人意4 小时前
从零开始学习嵌入式P32----网络基础之TCP
c语言·网络·学习·tcp/ip
神仙别闹5 小时前
基于 C++ 实现两个有序链表序列的交集
java·c++·链表
政企项目老覃7 小时前
大模型幻觉治理与自动评测:金融风控场景的落地实践
人工智能·算法·机器学习
是隼人7 小时前
buuctf-pwn inndy_echo(32位fmt)题解(学习过程持续更新)
c语言·学习·安全·pwn入门·ctf入门
淡海水7 小时前
08-03-不可变-ImmutableDictionary-TKey-TValue-与ImmutableHashSet-T-持久化哈希树
数据结构·算法·c#·哈希算法·dictionary·immutable
hansang_IR7 小时前
【题解】[APIO2023] 赛博乐园 / cyberland
c++·算法·图论
洛阳纸贵7 小时前
MATLAB-matlab基础知识
学习·算法·matlab
落羽的落羽8 小时前
【AI】快速理解AI应用的相关名词概念
linux·c++·人工智能·python·计算机网络·算法
刚入门的大一新生8 小时前
Linux-进程控制
linux·运维·服务器·c++