AW很是不解

# include <iostream>
# include <cstring>

using namespace std;

int main()
{
    int i = 0, j, k;
    int a[1000];
    string b[1000];
    int temp1;
    string temp2;
    while(cin >> a[i])
    {
        i++;
        if(cin.get() == '\n')
        {
            break;
        }
    }
    for(j = 0; j < i; j++)
    {
        cin >> b[j];
    }
    for(j = 0; j < i-1; j++)
    {
        for(k = 1; k < i; k++)
        {
            if(a[j] > a[k])
            {
                temp1 = a[j];
                a[j] = a[k];
                a[k] = temp1;
                
                temp2 = b[j];
                b[j] = b[k];
                b[k] = temp2;
            }
        }
    }
    for(j = 0; j < i - 1; j++)
    {
        cout << b[j] << endl;
    }
    cout << b[i-1];
    return 0;
}

0 条评论

目前还没有评论...

信息

ID
1389
难度
4
分类
模拟 点击显示
标签
(无)
递交数
2190
已通过
915
通过率
42%
被复制
9
上传者