蓝桥杯 大小写转换

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码


相关推荐
JMchen123几秒前
Android NDK开发从入门到实战:解锁应用性能的终极武器
android·开发语言·c++·python·c#·android studio·ndk开发
weixin_457760001 分钟前
深入解析 Beam Search:从原理到实践的高效解码算法
python·算法
ulimate_2 分钟前
anygrasp算法:调研与使用
算法
枳实-叶7 分钟前
50 道嵌入式音视频面试题
面试·职场和发展·音视频
愣头不青39 分钟前
96.不同的二叉搜索树
数据结构·算法·leetcode
AI科技星1 小时前
光速螺旋量子几何统一场论——基于 v ≡ c 公理的四大基本力全维度求导证明与精准数值验证
c语言·开发语言·人工智能·算法·机器学习·平面
ab1515171 小时前
3.27完成3(指针)、13、41、44(指针)、50、51、95、96、97
算法
程序猿编码1 小时前
隐匿注入型ELF加壳器:原理、设计与实现深度解析(C/C++ 代码实现)
c语言·网络·c++·elf·代码注入
AI成长日志1 小时前
【强化学习专栏】深度强化学习技术演进:DQN、PPO、SAC的架构设计与训练优化
人工智能·算法·架构
郭逍遥1 小时前
[Godot] JPS跳点寻路和RVO避障
算法·godot·启发式算法