【数组倍数去重】2022-11-26
缘由利用C语言去合并两组正整数-编程语言-CSDN问答
template <class 形参>
int 数组倍数去重(形参* a, 形参* aa, int n)
{//缘由https://ask.csdn.net/questions/7845726/53998477int x = 0, xx = 0, j = 0, s = 0;bool p = 1;aa[0] = a[0];qc:if (++x < n){xx = x;jc:if (xx--){ if (aa[xx] && a[x] % aa[xx] == 0)xx = p = 0; ++s; goto jc; }if (p)++j, aa[j] = a[x];elsep = 1;goto qc;}std::cout << s << "\n";return ++j;
}int a[40]{}, aa[40]{}, n = 40, b = 0, c = 0;std::cin >> c;
sr:if (b < c){ std::cin >> a[b], ++b; goto sr; }std::cin >> c; c += b;
sr1:if (b < c){ std::cin >> a[b], ++b; goto sr1; }n = c; 折扇排序(a, n);n = 数组倍数去重(a, aa, n); b = 0;sc:if (b < n){std::cout << aa[b] << " ", ++b;goto sc; }std::cout << "\n";