惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - o0myself0o

利用线程池实现多客户端和单服务器端Socket通讯(二):异步编程模型实现 生产者消费者模式,代码中碰到的疑问(已解决) 利用线程池实现多客户端和单服务器端Socket通讯(一):同步方式 Entity Framework 4.0 ObjectContext下的各种方法实践 题目:若干个不重复数,打乱顺序输出 wtf js(四) - o0myself0o - 博客园 wtf js(三) number的类型不是number wtf js(二) 应用中的单例模式 面试题:给你三个bool类型变量a, b, c,判断至少有两个为true javascript面向对象编程(一) - o0myself0o - 博客园 wtf js(一) - o0myself0o - 博客园 社区网站功能实现系列(三):社区页面无刷新回发的一种实现方式 社区网站功能实现系列(二):社区内容分享到别的SNS 社区网站功能实现系列(一):多国语言的实现 反射获取Class中Property的值 A*寻路初探 闲谈ASP.NET 2.0缓存技术 使用 jQuery 简化 Ajax 开发
算法:给定两个已从小到大排好序的整型数组arrA和arrB,将两个数组合并成arrC,使得arrC也要按从小到大的顺序排好序
o0myself0o · 2010-07-07 · via 博客园 - o0myself0o

namespace Sort
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * 给定两个已从小到大排好序的整型数组arrA和arrB
             * 将两个数组合并成arrC,使得arrC也要按从小到大的顺序排好序
             */
            int[] arrA = new int[] { 1, 3, 5, 9, 10 };
            int[] arrB = new int[] { 2, 4, 6, 7, 8 };

            int[] arrC = new int[arrA.Length + arrB.Length];
            int k = 0;

            int m = 0;
            int n = 0;

            for (int i = m; i < arrA.Length; i++)
            {
                for (int j = n; j < arrB.Length; j++)
                {
                    if (arrA[i] < arrB[j])
                    {
                        arrC[k++] = arrA[i];
                        m++;
                        n = j;
                        if (i == arrA.Length - 1)
                        {
                            for (int x = j; x < arrB.Length; x++)
                            {
                                arrC[k++] = arrB[x];
                            }
                        }
                        break;
                    }
                    else
                    {
                        arrC[k++] = arrB[j];
                        m = i;
                        n++;
                        if (j == arrB.Length - 1)
                        {
                            for (int x = i; x < arrA.Length; x++)
                            {
                                arrC[k++] = arrA[x];
                            }
                        }
                        continue;
                    }
                }
            }

            for (int i = 0; i < arrC.Length; i++)
            {
                Console.WriteLine(arrC[i]);
            }
            Console.Read();
        }
    }
}