编程:有两已排序好的字符串S1,S2,将它们合并为S且S也是排序好的。如:S1=abc,S2=aabbc,则S=aaabbbcc。

 // string_merdge.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"
#include "string.h"
 
void main()
{
        char a[]="abfz";
        char b[]="bbesy";
        char *c = new char[strlen(a)+strlen(b)+1];
        char *pa = a;
        char *pb = b;
        char *pc = c;
        while(*pa || *pb)
        {
               if(*pa < *pb || *pb == '\0')
               {
                       *pc = *pa;
                       pa++;
               }else{
                       *pc = *pb;
                       pb++;
               }
               pc++;
        }
        *pc='\0';
        printf("%s\n",a);
        printf("%s\n",b);
        printf("%s\n",c);
}