跳到正文

题解

P8761 [蓝桥杯 2021 国 BC] 大写 题解

Not_lazy约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年5月29日
更新
2026年5月29日
篇幅
约 1 分钟
获赞
2
题目
P8761

版本

  1. v1当前

题意:将字符串中的小写字母转化为大写即可。

这里介绍一个字符串函数—— toupper()。对于一个字母 cc,若它有对应的大写字母,该函数就将其转换为大写字母,否则保持不变。

C++
#include<bits/stdc++.h>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(islower(s[i]))s[i]-=32; 
	}
	cout<<s<<endl;
	return 0;
}
原文