文章

13

粉丝

120

获赞

4

访问

10.3k

头像
首字母大写 题解:
P1240 北京大学机考题
发布于2023年5月5日 23:10
阅读数 809

注意事项:

1. 可能是大写字母,要判断是小写之后在处理(如果使用toupper就不用判断)

2. 模拟判断前一位首先处理s[0]

3. 使用库函数isalpha和islower和toupper简化代码

AC代码

#include <bits/stdc++.h>


#define fi first
#define endl '\n'
#define se second
#define pp pop_back
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define all(a) begin(a),end(a)
#define lp(i,j,k) for(int i=int(j);i<=int(k);i++)
#define rlp(i,j,k) for(int i=int(j);i>=int(k);i--)
#define IO std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template <class T> inline void chkmax(T &x,T y) {if(x<y) x=y;}
template <class T> inline void chkmin(T &x,T y) {if(x>y) x=y;}

const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
const int TN = 1e3 + 10;
const int INF = 0x3f3f3f3f;
int dx[8] = {0,1,0,-1,1,-1,-1,1};
int dy[8] = {1,0,-1,0,1,-1,1,-1};
int a[N],b[N],f[N];
i...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发