#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
bool cmp(char a,char b)
{
return a > b;
}
char s[100];
char ans[100];
int main()
{
scanf("%s", s);
int n = 0;
while(1)
{
if(s[n] == 0)
break;
n++;
}
int mid = n / 2;
if (n % 2 == 0){
sort(s, s + mid,cmp);
sort(s + mid, s + n);
for (int i = 0; i < mid; i++)
{
ans[i] = s[i + mid];
ans[i + mid] = s[i];
}
}
else{
sort(s, s + mid,cmp);
sort(s + mid + 1, s + n);
for (int i = 0; i < mid; i++)
{
ans[i] = s[i + mid + 1];
ans[i + mid + 1] = s[i];
}
ans[mid] = s[mid];
}
printf("%s", ans);
}
#include <stdio.h>
#include <string.h>
int main()
{
char a[10], s[10];
scanf("%s %s", a, s);
if (!strcmp(a, "A#"))
printf("Bb %s", s);
else if (!strcmp(a, "Bb"))
printf("A# %s", s);
else if (!strcmp(a, "C#"))
printf("Db %s", s);
else if (!strcmp(a, "Db"))
printf("C# %s", s);
else if (!strcmp(a, "D#"))
printf("Eb %s", s);
else if (!strcmp(a, "Eb"))
printf("D# %s", s);
else if (!strcmp(a, "F#"))
printf("Gb %s", s);
else if (!strcmp(a, "Gb"))
printf("F# %s", s);
else if (!strcmp(a, "G#"))
printf("Ab %s", s);
else if (!strcmp(a, "Ab"))
printf("G# %s", s);
else
printf("unique");
return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s[10];
for (int i = 0; i < 10;i++)
{
cin >> s[i];
}
sort(s, s + 10);
for (int i = 0; i < 10; i++)
{
cout << s[i] << " ";
}
}
#include <stdio.h>
#include <string.h>
void stringmerge(char s1[],char s2[])
{
int len1 = strlen(s1);
int len2 = strlen(s2);
int i = 0;
for (i = len1; i <= len1 + len2;++i){
s1[i] = s2[i - len1];
}
}
int main()
{
char s1[100], s2[100];
scanf("%s %s", s1, s2);
stringmerge(s1, s2);
printf("%s", s1);
}
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char s[1000];
char a[1000];
char ch;
int i = 0;
int j = 0;
cin.getline(s, 1000);
for (int i = 0, j = 0; i < strlen(s);i++){
if(s[i] == 'y' && s[i+1] == 'o' && s[i+2] == 'u'){
a[j] = 'w';
a[j + 1] = 'e';
j += 2;
i += 2;
}
else{
a[j] = s[i];
j++;
}
}
printf("%s", a);
}
#include <stdio.h>
#include <string.h>
int main()
{
char s[1000];
scanf("%s", s);
int up = 0, down = 0;
for (int i = 0; i < strlen(s);i++)
{
if(s[i] == 'S'){
printf("WA");
return 0;
}
if(s[i] == 'U'){
up++;
}
else{
down++;
}
}
int a, b, all;
a = up;
b = down;
all = a + b;
if ((double)up / (double)(up + down) > 0.503 || (double)up / (double)(up + down) < 0.497)
{
printf("Fail");
return 0;
}
for (int i = 2; i <= a; i++)
{
if (a % i == 0 && all % i == 0)
{
a = a / i;
all = all / i;
}
}
printf("%d/%d", a, all);
}
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string, int> m = {
{"I", 1},
{"II", 2},
{"III", 3},
{"IV", 4},
{"V", 5},
{"VI", 6},
{"VII", 7},
{"VIII", 8},
{"IX", 9},
{"X", 10},
{"XI", 11},
{"XII", 12}
};
string s;
cin >> s;
cout << m[s];
}
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
char s1[128] = "", s2[128] = "";
cin.getline(s1, 128);
int len = strlen(s1);
char *p1 = s1 + len - 1; // 字符串尾部指针
int flag = 0; // 不是字母
int count = 0; // 字母个数
for (int i = 0; i <= len; ++i)
{
if (*p1 >= 'a' && *p1 <= 'z' ||
*p1 >= 'A' && *p1 <= 'Z') // 如果是字母
{
count++; // 记录字母个数
flag = 1; // 是字母
}
else
{
flag = 0; // 不是字符
}
if (!flag && count) // 出现不是字母且字母个数不为0,进行单词连接
{
strncat(s2, p1 + 1, count); // 连接单词
if (i != len) // 最后一个单词没有空格
strcat(s2, " ");
flag = 1; // 设定是字母
count = 0; // 字母个数统计归0
}
p1--; // 移动字符串指针
}
printf("%s\n", s2); // 有回车
return 0;
}
下面的答案是错的,尽管我感觉我写的是对的,但是始终是WA,有知道错在哪的给我说一下
#include <iostream>
#include <cstring>
using namespace std;
int num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0;
void count(char s[])
{
for (int i = 0; i < strlen(s); i++)
{
if(s[i] >= 'A' && s[i] <= 'Z')
num1++;
else if(s[i] >= 'a' && s[i] <= 'z')
num2++;
else if(s[i] >= '0' && s[i] <= '9')
num3++;
else if(s[i] == ' ')
num4++;
else
num5++;
}
}
int main()
{
char s1[1000], s2[1000], s3[1000];
cin.getline(s1, 1000);
cin.getline(s2, 1000);
cin.getline(s3, 1000);
count(s1);
count(s2);
count(s3);
cout << num1 << " " << num2 << " " << num3 << " " << num4 << " " << num5 ;
}
#include <stdio.h>
#include <string.h>
int stringcompare(char s1[],char s2[])
{
for (int i = 0; i < strlen(s1);i++)
{
if(s1[i] != s2[i])
{
return s1[i] - s2[i];
}
}
return 0;
}
int main()
{
char s1[100], s2[100];
scanf("%s%s", s1, s2);
printf("%d", stringcompare(s1, s2));
}