问一下为什么在openjudge上显示错误(关于C++倒置排序)

2023-12-29 04:09:18
题目为

#include <iostream>
using namespace std;
int main()
{
    int N, n, a, b , m;
    int arr1[80], arr2[80];
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> n;
        for (int j = 0; j < n; j++)
        {
            b = 0;
            cin >> arr1[j];
            m=arr1[j] ;
            while (m != 0)
            {
                a = m % 10;
                b = b * 10 + a;
                m = m / 10;
            }
            arr2[j] = b;
        }
        for (int p = 0; p < n-1; p++)
        {
            for (int j = 0; j <n - p-1; j++)
            {
                if (arr2[j] > arr2[j + 1])
                {
                    int temp = arr1[j];
                    arr1[j] = arr1[j + 1];
                    arr1[j + 1] = temp;
                }
            }

        }
        for (int p = 0; p < n; p++)
            cout << arr1[p] << " ";
        cout << endl;
    }
    return 0;
}

文章来源:https://blog.csdn.net/2302_80687305/article/details/135280256
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。