简体   繁体   English

[C ++ 14]我正在使用配对,但没有输出

[英][C++14]I'm using pair but no output

I was writing a code to sort and output the number by using "pair". 我正在编写代码以使用“ pair”对数字进行排序和输出。 I tried some cases bat there was no output. 我尝试了一些情况,蝙蝠没有输出。 How should I rewrite the code? 我应该如何重写代码?

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    int k, i, n;
    cin >> n;
    pair<int, int> a[n];
    for (i = 0; i < n; i++) {
        cin >> k;
        a[i].first = -k;
        a[i].second = i + 1;
    }
    sort(a, a + n);
    for (i = 0; i++; i < n) {
        cout << a[i].second;
    }
}
for(i=0;i++;i<n){

您打算将其编写为:

for(i=0;i<n;i++){

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM