当前位置:网站首页>ZZULIOJ 1124: Merge two sorted arrays
ZZULIOJ 1124: Merge two sorted arrays
2022-08-10 10:03:00 【An Ran_】
1124: Merge two ordered arrays
span>Time limit: 1 Sec Memory limit: 128 MBTitle descriptionIt is known that there are m elements in ascending order in array a, and n elements in descending order in array b. The programming stores all elements in a and b into array c in descending order.
EnterThe input has two lines, the first line is first a positive integer m, then m integers; the second line is first a positive integer n, then n integers, m, n are both less than or equal to 1000000.
OutputOutput the combined m+n integers, separated by spaces.The output is on one line.
Sample input Copy4 1 2 5 73 6 4 2Sample output Copy7 6 5 4 2 2 1
#include #include int a[1000000];int b[1000000];int c[2000000];void merge(int*a,int m,int*b,int n);void print(int *c,int cnt);int cmp(const void*p1,const void*p2);//The overall idea is stored in a new array cint main(){int m,n;int i,j;scanf("%d",&m);for(i=0;ib[j]) c[k++]=a[i++];else c[k++]=b[j++];}while(i 边栏推荐
猜你喜欢
随机推荐
The web project accesses static resources inside the reference jar
「业务架构」TOGAF建模:组织分解图(组织映射)
「数据架构」数据模型,数据字典,数据库模式 和ERD的比较
杭电多校七 1008-Triangle Game(博弈)
CatchAdmin实战教程(四)Table组件之自定义基础页面
用高质量图像标注数据加速AI商业化落地
【Software Exam System Architect】System Reliability Analysis and Design ① System Reliability Analysis
ES关于文档的基本操作
shell iterates over folders and outputs
How to understand the difference between BIO, NIO, and AIO
Development environment variable record under win
JS高级 之 使用 Iterator - Generator
IDEA中xml文件头报错:URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)
"Guangzhou highway engineering measures for the supervision and administration of production safety, and revised from six aspects
Which is the strongest workflow engine for "Technology Selection"?Chief Architecture Helps You Pick
VBA: 遍历文件抓取指定条件的数据
Message Queuing Overview
用.bat文件做Airtest脚本的多设备批量运行
LCD模块如何建立联系分析
重学冒泡排序









