// ------------1t------------------
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int gys(int a, int b)
{
while (a != b)
{
if (a > b)
{
a = a - b;
}
else
{
b = b - a;
}
}
return a;
}
int gbs(int a, int b)
{
return a * b / gys(a, b);
}
//打印输出
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d\n", gys(a, b), gbs(a, b));
// 暂停
return 0;
}
// ------------2t------------------
#include<stdio.h>
float findmax(float a, float b, float c)
{
float t = a;
if (t < b) t = b;
if (t < c) t = c;
return t;
}
//打印输出
int main()
{
float a, b, c;
scanf("%f %f %f", &a, &b, &c);
printf("%.3f\n", findmax(a, b, c));
// 暂停
return 0;
}
// ------------3t------------------
#include<stdio.h>
int fbnq(int n)
{
if (n == 1) return 1;
if (n == 2) return 1;
return fbnq(n - 1) + fbnq(n - 2);
}
//打印输出
int main()
{
int n;
scanf("%d", &n);
printf("%d\n", fbnq(n));
// 暂停
return 0;
}
// ------------4t------------------
#include<stdio.h>
float pingjun(float x[], int n)
{
int i;
float total = 0;
for (i = 0; i < n; ++i){
total += x[i];
}
return total / ((float)n);
}
//打印输出
int main()
{
int n, i;
float fenarr[10];
scanf("%d", &n);
for (i = 0; i < n; ++i){
scanf("%f", &fenarr[i]);
}
printf("%.2f\n", pingjun(fenarr, n));
// 暂停
return 0;
}
// ------------5t------------------
#include<stdio.h>
void fanxu_string(char s[])
{
char t;
int i, n = 0;
for (char* p = s; *p++; ++n);
for (i = n / 2; i--;){
t = s[i];
s[i] = s[n - i - 1];
s[n - i - 1] = t;
}
}
//打印输出
int main()
{
char str[200] = {};
scanf("%s", str);
fanxu_string(str);
printf("%s\n", str);
// 暂停
return 0;
}
// ------------6t------------------
#include<stdio.h>
int isPalindrome(char s[])
{
int i, n = 0;
for (char* p = s; *p++; ++n);
char* e = s + n - 1;
for (i = n / 2; i--;){
if (*s++ != *e--)
return 0;
}
return 1;
}
//打印输出
int main()
{
int n, i;
char str[20][100] = {};
scanf("%d", &n);
for (i = 0; i < n; ++i){
scanf("%s", str[i]);
}
for (i = 0; i < n; ++i){
if (isPalindrome(str[i]))
printf("Yes\n");
else
printf("No\n");
}
// 暂停
return 0;
}
// ------------7t------------------
#include<stdio.h>
void sort(int a[], int n)
{
int i,j;
for (i = 0; i < n - 1; i++){
for (j = 0; j < n - i - 1; j++){
if (a[j] > a[j + 1]){
int tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
}
}
}
}
void desc(int a[], int n)
{
int i, j;
for (i = 0; i < n - 1; i++){
for (j = n -1; j > i; --j){
if (a[j] > a[j - 1]){
int tmp = a[j];
a[j] = a[j - 1];
a[j - 1] = tmp;
}
}
}
}
int find(int a[], int n, int value)
{
while (n--){
if (a[n] == value)
break;
}
return n;
}
void display(int a[], int n)
{
int i;
for (i = 0; i < n; ++i){
printf("%d", a[i]);
if (i + 1 < n) printf(" ");
}
printf("\n");
}
int fenge(int a[], int n)
{
int i, c = 0, d = n-1;
int arr[20] = {};
for (i = n; i--; arr[i] = a[i]);
for (i = 0; i < n; ++i){
if (arr[i] & 1) a[c++] = arr[i];
else a[d--] = arr[i];
}
return c;
}
//打印输出
int main()
{
int n =1, i, k, a, len;
int arrTbl[40][20] = { { } };
int dataTbl[40] = {};
int* arr;
scanf("%d", &n);
for (k = 0; k < n; ++k){
for (i = 0; i < 10; ++i){
scanf("%d", &arrTbl[k][i]);
}
scanf("%d", &dataTbl[k]);
}
for (k = 0; k < n; ++k){
len = 10;
a = dataTbl[k];
arr = arrTbl[k];
do{
int idx = find(arr, 10, a);
if (a & 1){
if (idx != -1){
arr[idx] = arr[9];
sort(arr, 9);
len = 9;
break;
}
}
else{
if (idx == -1){
arr[10] = a;
desc(arr, 11);
len = 11;
break;
}
}
idx = fenge(arr, 10);
desc(arr, idx);
desc(&arr[idx], 10 - idx);
} while (false);
display(arr, len);
}
// 暂停
return 0;
}