#include "stdafx.h" #include <stdio.h> #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { int a[5] = {0,2,5,7,8}; int b[5] = {1,3,4,6,9}; int c[10],i,x,y,z; x=0;y=0;z=0; while(x<5&&y<5) { if(a[x]<b[y]) { c[z]=a[x]; x++; } else{ c[z]=b[y]; y++; } z++; } while(x<5) { c[z]=a[x]; x++; z++; } while(y<5) { c[z]=b[y]; y++; z++; } for(i=0;i<10;i++) { printf("%5d",c[i]);} system("pause"); return 0; }
时间: 2024-10-29 19:08:13