2020 408 数据结构 算法题
作者:互联网
#include<iostream> using namespace std; void solution(int a[], int aLength, int b[], int bLength, int c[], int cLength) { int res[3] = { a[0],b[0],c[0] }; int i = 0, j = 0, k = 0; while (i < aLength && j < bLength && k < cLength) { if (a[i] <= b[j] && a[i] <= c[k]) { if (i == aLength-1) break; i++; } else if (b[j] <= a[i] && b[j] <= c[k]) { if (j == bLength-1) break; j++; } else if (c[k] <= a[i] && c[k] <= b[j]) { if (k == cLength - 1) break; k++; } } cout << a[i] << " " << b[j] << " " << c[k]; } int main() { int a[3]={-1,0,9}; int b[4] = { -25,-10,10,11 }; int c[5]={2,9,17,30,41}; solution(a, 3, b, 4, c, 5); }
标签:std,bLength,int,2020,&&,数据结构,cLength,aLength,408 来源: https://www.cnblogs.com/Stone-Sea/p/16486063.html