提交记录 #189
提交时间:2024-11-12 16:56:20
语言:c
状态:Accepted
编译情况:编译成功
code.c: In function ‘main’:
code.c:9:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100]’ [-Wformat=]
9 | scanf("%s", &words1);
| ~^ ~~~~~~~
| | |
| | char (*)[100]
| char *
code.c:14:9: warning: unused variable ‘q’ [-Wunused-variable]
14 | int q = 0;
| ^
code.c:13:10: warning: unused variable ‘kong’ [-Wunused-variable]
13 | char kong[100];
| ^~~~
固定测试点#1:
固定测试点#2:
固定测试点#3:
固定测试点#4:
固定测试点#5:
固定测试点#6:
固定测试点#7:
固定测试点#8:
固定测试点#9:
额外测试点#3600:
34【字符】合并字符串
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int main()
{
char words1[100];
char words2[100];
scanf("%s", &words1);
getchar();
fgets(words2, sizeof(words2), stdin);
words2[strcspn(words2, "\n")] = 0;
char kong[100];
int q = 0;
int length1 = strlen(words1);
int length2 = strlen(words2);
for (int i = 0; i < length2; i++)//2---i
{
int position=0;
while (position < length1 && words1[position] < words2[i])
{
position++;
}
for (int j = length1; j >position ; j--)
{
words1[j] = words1[j - 1];
}
words1[position] = words2[i];
length1++;
}
words1[length1] = '\0';
printf("%s\n", words1);
}