蓝桥杯 大小写转换

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码


相关推荐
追随者永远是胜利者1 分钟前
(LeetCode-Hot100)461. 汉明距离
java·算法·leetcode·职场和发展·go
爱编码的小八嘎3 分钟前
第3章 Windows运行机理-3.1 内核分析(4)
c语言
郝学胜-神的一滴3 分钟前
单例模式:从经典实现到Vibe Coding时代的思考
开发语言·c++·程序人生·单例模式·设计模式·多线程
努力学算法的蒟蒻4 分钟前
day90(2.19)——leetcode面试经典150
算法·leetcode·面试
啊阿狸不会拉杆11 分钟前
《计算机视觉:模型、学习和推理》第 5 章-正态分布
人工智能·python·学习·算法·机器学习·计算机视觉·正态分布
样例过了就是过了17 分钟前
LeetCode热题100 缺失的第一个正数
数据结构·算法·leetcode
样例过了就是过了19 分钟前
LeetCode热题100 除了自身以外数组的乘积
数据结构·算法·leetcode
yyjtx24 分钟前
DHU上机打卡D26
数据结构·c++·算法
智者知已应修善业25 分钟前
【蓝桥杯单词分析最多字母次数并列字典最小输出】2025-4-15
c语言·c++·经验分享·笔记·算法·蓝桥杯
MR_Promethus26 分钟前
【C++11】volatile 关键字
开发语言·c++·volatile