蓝桥杯 大小写转换

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码


相关推荐
ad钙奶长高高6 分钟前
【C语言】扫雷游戏详解
c语言
亮剑20187 分钟前
第1节:C语言初体验——环境、结构与基本数据类型
c++
William_wL_34 分钟前
【C++】类和对象(下)
c++
William_wL_1 小时前
【C++】内存管理
c++
星星火柴9362 小时前
笔记 | C++面向对象高级开发
开发语言·c++·笔记·学习
Coovally AI模型快速验证2 小时前
当视觉语言模型接收到相互矛盾的信息时,它会相信哪个信号?
人工智能·深度学习·算法·机器学习·目标跟踪·语言模型
悲伤小伞2 小时前
Linux_Socket_UDP
linux·服务器·网络·c++·网络协议·udp
电院工程师2 小时前
SIMON64/128算法Verilog流水线实现(附Python实现)
python·嵌入式硬件·算法·密码学
轮到我狗叫了2 小时前
力扣.84柱状图中最大矩形 力扣.134加油站牛客.abb(hard 动态规划+哈希表)牛客.哈夫曼编码
算法·leetcode·职场和发展
丛雨要玩游戏2 小时前
字符函数和字符串函数
c语言·开发语言·算法