10.6作业

一、

1.B 2.A 3.C 4.D 5.A 6.A 7.A 8.C 9.A 10.B 11.A 12.C

二、

1.abc

2.I like it 、A like it

3.30 10 30 、n Learning

三、

cpp 复制代码
#include <myhead.h>
#define Len 100

void Sort(char arr[],int n)
{
	int i,j;
	char temp;
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(arr[j]>arr[j+1])
			{
				temp=arr[j];
				arr[j]=arr[j+1];
				arr[j+1]=temp;
			}
		}
	}
}

int main(int argc, const char *argv[])
{
	char a[Len],b[Len],c[Len];
	printf("请输入字符串a:");
	fgets(a,Len,stdin);
	printf("请输入字符串b:");
	fgets(b,Len,stdin);

	int len_a=strlen(a);
	if(a[strlen(a)-1]=='\n')
	{
		a[len_a-1]='\0';
		len_a--;
	}
	int len_b=strlen(b);
	if(b[strlen(b)-1]=='\n')
	{
		b[len_b-1]='\0';
		len_b--;
	}
	//合并两个字符串
	strcpy(c,a);
	strcat(c,b);

	int temp_len=len_a+len_b;

	//对合并的字符串进行排序
	Sort(c,temp_len);

	printf("排序后为:%s\n",c);
	return 0;
}
相关推荐
sali-tec7 小时前
C# 基于halcon的视觉工作流-章66 四目匹配
开发语言·人工智能·数码相机·算法·计算机视觉·c#
小明说Java7 小时前
常见排序算法的实现
数据结构·算法·排序算法
行云流水20198 小时前
编程竞赛算法选择:理解时间复杂度提升解题效率
算法
smj2302_7968265210 小时前
解决leetcode第3768题.固定长度子数组中的最小逆序对数目
python·算法·leetcode
cynicme10 小时前
力扣3531——统计被覆盖的建筑
算法·leetcode
core51211 小时前
深度解析DeepSeek-R1中GRPO强化学习算法
人工智能·算法·机器学习·deepseek·grpo
mit6.82411 小时前
计数if|
算法
a伊雪11 小时前
c++ 引用参数
c++·算法
Data_agent12 小时前
1688获得1688店铺列表API,python请求示例
开发语言·python·算法
2301_7644413312 小时前
使用python构建的应急物资代储博弈模型
开发语言·python·算法