全部评论 4

  • #include <bits/stdc++.h>
    using namespace std;
    const int MAXN = 11;
    int a[MAXN];
    int evens[MAXN];
    int odds[MAXN];
    int main()
    {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q = 0, w = 0;
    for (int i = 0; i < 10; i++)
    {
    cin >> a[i];
    if (a[i] % 2 == 0) evens[q++] = a[i];
    else odds[w++] = a[i];
    }
    for (int i = 0; i < q - 1; i++)
    {
    for (int j = 0; j < q - i - 1; j++)
    {
    if (evens[j] > evens[j + 1])
    {
    int temp = evens[j];
    evens[j] = evens[j + 1];
    evens[j + 1] = temp;
    }
    }
    }
    for (int i = 0; i < w - 1; i++)
    {
    for (int j = 0; j < w - i - 1; j++)
    {
    if (odds[j] < odds[j + 1])
    {
    int temp = odds[j];
    odds[j] = odds[j + 1];
    odds[j + 1] = temp;
    }
    }
    }
    for (int i = 0; i < w; i++)
    {
    if (i > 0) cout << " ";
    cout << odds[i];
    }
    for (int i = 0; i < q; i++)
    {
    cout << " " << evens[i];
    }
    cout << endl;
    return 0;
    }

    49分钟前 来自 浙江

    0
  • 52分钟前 来自 浙江

    0
  • 53分钟前 来自 浙江

    0
  • 1小时前 来自 湖南

    0

热门讨论