#include <iostream>
using namespace std;
int main() {
int a[110];
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < k / 2; i++) {
swap(a[i], a[k - 1 - i]);
}
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
return 0;
}
202012简单密码c++
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
char a[220];
gets(a);
for (int i = 0; i < strlen(a); i++) {
if (a[i] >= 'A' && a[i] <= 'E') {
a[i] = a[i] + 21;
} else if (a[i] >= 'F' && a[i] <= 'Z') {
a[i] = a[i] - 5;
}
}
cout << a;
return 0;
}
202012错误探测c++
#include <iostream>
using namespace std;
void shuru();
void tongji1();
int a[110][110] = { 0 };
int n;
int main() {
shuru();
tongji1();
int cnt1 = 0; //奇数列的个数
int x = 0;
for (int i = 1; i <= n; i++) //统计奇数列有几个
{
if (a[0][i] % 2 != 0) {
cnt1++;
x = i;
}
}
int cnt2 = 0; //奇数行的个数
int y = 0;
for (int i = 1; i <= n; i++) //统计奇数行有几个
{
if (a[i][0] % 2 != 0) {
cnt2++;
y = i;
}
}
if (cnt1 == 0 && cnt2 == 0) {
cout << "OK" << endl;
} else if (cnt1 == 1 && cnt2 == 1) {
cout << y << " " << x << endl;
} else if (cnt1 > 1 || cnt2 > 1) {
cout << "Corrupt" << endl;
}
return 0;
}
void shuru() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
}
}
}
void tongji1() {
for (int i = 1; i <= n; i++) //行
{
for (int j = 1; j <= n; j++) //列
{
if (a[i][j] == 1) {
a[i][0]++; //对应行头(0)位置++
a[0][j]++; //对应列头(0)位置++
}
}
}
}
202012奇数单增序列c++
#include <iostream>
using namespace std;
int a[510];
int la = 0;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int s;
cin >> s;
if (s % 2 == 1) {
a[la] = s;
la++;
}
}
for (int i = 0; i < la - 1; i++) {
for (int j = 0; j < la - 1 - i; j++) {
if (a[j] > a[j + 1]) {
swap(a[j], a[j + 1]);