数组查找及替换

code

#include<algorithm>
#include<iostream>
using namespace std;
int a[105], b, n;
int main() {
	ios::sync_with_stdio(false);
	while (cin >> n >> b) {
		//TODO input
		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		sort(a, a + n);
		for (int i = 0; i < n; i++) {
			if (a[i] % b != 0) {
				if (a[i] >= 'A' && a[i] <= 'Z') {
					cout << (char)('A' + (a[i] - 65)) << ' ';
				} else {
					cout << a[i] << ' ';
				}
			}
		}
	}
	return 0;
}

thought

ascii translate:
int minus 65 add 'A'

作者:Jesee

出处:https://www.cnblogs.com/jeseesmith/p/15861207.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   ggexs  阅读(109)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话
more_horiz
keyboard_arrow_up dark_mode palette
选择主题
点击右上角即可分享
微信分享提示