数组查找及替换
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'