错误:没有匹配函数来调用‘std::vector<std::pair<double, std::pair<long long int, long long int> > >::push_back(double&, long long int&)

问题描述 投票:0回答:1
#define ll long long
#define fi first
#define se second
#include <bits/stdc++.h>
using namespace std;

int main(){
    ll n,m,a,b,q,i,j;
    vector<pair <double, pair<ll,ll> >> suhu;
    cin>>n>>m>>a>>b>>q;
    ll x,y; double suhuxy;
    for(i=1; i<=n; i++){
        for(j=1; i<=m; j++){
            x = b + j;
            y = a + i;
            suhuxy = x/y;
            suhu.push_back(suhuxy, (x,y));
        }
    }   
    return 0;
}

我尝试通过

double
函数输入一个
ll
,一个
ll
和另一个
push_back()
。但是,它说这个错误:

prog.cpp:27:32: error: no matching function for call to ‘std::vector<std::pair<double, std::pair<long long int, long long int> > >::push_back(double&, long long int&)’
    suhu.push_back(suhuxy, (x,y));
c++ vector std-pair push-back
1个回答
0
投票

您的

vector
包含一个
pair
数组,所以这就是
push_back()
所期望的,但这不是您给它的。

试试这个:

suhu.push_back(make_pair(suhuxy, make_pair(x,y)));

或者:

suhu.push_back({suhuxy, {x,y}});
© www.soinside.com 2019 - 2024. All rights reserved.