蓝桥杯 大小写转换

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码


相关推荐
是娇娇公主~13 分钟前
Lambda表达式详解
数据结构·c++
leaves falling18 分钟前
C++ string 类:从入门到模拟实现
开发语言·c++
样例过了就是过了39 分钟前
LeetCode热题100 柱状图中最大的矩形
数据结构·c++·算法·leetcode
wsoz1 小时前
Leetcode哈希-day1
算法·leetcode·哈希算法
阿Y加油吧1 小时前
LeetCode 二叉搜索树双神题通关!有序数组转平衡 BST + 验证 BST,小白递归一把梭
java·算法·leetcode
liuyao_xianhui2 小时前
优选算法_最小基因变化_bfs_C++
java·开发语言·数据结构·c++·算法·哈希算法·宽度优先
AI+程序员在路上2 小时前
Linux C 条件变量阻塞线程用法:等待时CPU占用率为0
linux·运维·c语言
jimy12 小时前
C语言实现-----面向对象编程
c语言·数据结构
黎阳之光2 小时前
数智技术如何赋能空天地一体化,领跑低空经济新赛道
大数据·人工智能·算法·安全·数字孪生
cch89182 小时前
易语言与C++:编程语言终极对决
开发语言·c++