21年
45题
#include <stdio.h>
#define N 1010
int arr[N];
// 选择排序
void sort(int *arr, int len) {
for (int i = 0; i < len - 1; i++) {
int m = i;
for (int j = i + 1; j < len; j++) {
if (arr[j] < arr[m]) m = j;
}
int t = arr[i];
arr[i] = arr[m];
arr[m] = t;
}
}
int main() {
int x, y;
scanf("%d%d", &x, &y);
int pa = 0;
while (x) {
arr[pa++] = x % 10;
x /= 10;
}
while (y) {
arr[pa++] = y % 10;
y /= 10;
}
sort(arr, pa);
for (int i = pa - 1; i >= 0; i--) printf("%d", arr[i]);
return 0;
}
46题
#include <stdio.h>
#define N 1010
int arr[N];
// 选择排序
void sort(int *arr, int len) {
for (int i = 0; i < len - 1; i++) {
int m = i;
for (int j = i + 1; j < len; j++) {
if (arr[j] < arr[m]) m = j;
}
int t = arr[i];
arr[i] = arr[m];
arr[m] = t;
}
}
int main() {
int x, y;
scanf("%d%d", &x, &y);
int pa = 0;
while (x) {
arr[pa++] = x % 10;
x /= 10;
}
while (y) {
arr[pa++] = y % 10;
y /= 10;
}
sort(arr, pa);
for (int i = 0; i < pa; i++) printf("%d", arr[i]);
return 0;
}
47题
#include <stdio.h>
#define N 1010
int arr[N];
// 选择排序
void sort(int *arr, int len) {
for (int i = 0; i < len - 1; i++) {
int m = i;
for (int j = i + 1; j < len; j++) {
if (arr[j] < arr[m]) m = j;
}
int t = arr[i];
arr[i] = arr[m];
arr[m] = t;
}
}
int main() {
int x, y;
scanf("%d%d", &x, &y);
int pa = 0;
while (x) {
arr[pa++] = x % 10;
x /= 10;
}
while (y) {
arr[pa++] = y % 10;
y /= 10;
}
sort(arr, pa);
if (!arr[0]) {
for (int i = 1; i < pa; i++) {
if (arr[i]) {
int t = arr[0];
arr[0] = arr[i];
arr[i] = t;
break;
}
}
for (int i = 0; i < pa; i++) printf("%d", arr[i]);
}
else {
for (int i = 0; i < pa; i++) printf("%d", arr[i]);
}
return 0;
}
48题
#include <stdio.h>
int res;
int condition1(int x) {
if (x == 1) return 0;
int cnt = 0;
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) cnt++;
}
if (cnt) return 0;
return 1;
}
int condition2(int x) {
if (x < 10) return 1;
int arr[10010], cnt = 0;
while (x) {
arr[cnt++] = x % 10;
x /= 10;
}
int flag = 1;
for (int i = 0; i < cnt / 2; i++) {
if (arr[i] != arr[cnt - 1 - i]) {
flag = 0;
break;
}
}
if (flag) return 1;
return 0;
}
int condition3(int x) {
int sum = 0;
while (x) {
sum += x % 10;
x /= 10;
}
if (sum % 7) return 0;
return 1;
}
int main() {
int n; scanf("%d", &n);
for (int i = 2; i <= n; i++) {
if (condition1(i) && condition2(i) && condition3(i)) {
res++;
// printf("%d ", i);
}
}
// printf("\n");
printf("%d\n", res);
return 0;
}