haidddq 2023-09-01 19:59 采纳率: 66.7%
浏览 6
已结题

C++ goto 编译错误

今天在代码里写了个goto,然后就报错了,有人帮忙看看吗

#include<bits/stdc++.h>
using namespace std;
struct _{
    int t,price;
};
struct cmp{
    bool operator()(_ a,_ b){
        return a.t>b.t;
    }
};
int n,m,price[100005],t[100005],ans;
priority_queue<_,vector<_>,cmp> ticket;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int v;
        scanf("%d%d%d",v,price[i],t[i]);
        if(v==0){
            ans+=price[i];
            ticket.emplace(t[i],price[i]);
        }
        else if(v==1){
            lable:
            
            goto lable;
        }
    }
    return 0;
}

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/x86_64-w64-mingw32/bits/c++allocator.h 33 0 In file included from D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/x86_64-w64-mingw32/bits/c++allocator.h

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/new_allocator.h 0 -1 In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = _; _Args = {int&, int&}; _Tp = _]':

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/alloc_traits.h 537 17 required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = _; _Args = {int&, int&}; _Tp = _; allocator_type = std::allocator<_>]'

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/vector.tcc 117 30 required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = _; _Alloc = std::allocator<_>]'

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stl_queue.h 756 18 required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int&, int&}; Tp = ; Sequence = std::vector<_>; Compare = cmp]'

D:/用户文件/桌面/C++/临时/未命名1.cpp 20 18 required from here

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/new_allocator.h 187 11 [错误] new initializer expression list treated as compound expression [-fpermissive]

D:/杞欢/灏忕唺鐚獵++/RedPanda-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/new_allocator.h 187 11 [错误] no matching function for call to '
::
(int&)'

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] candidate: '
::
()'

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] candidate expects 0 arguments, 1 provided

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] candidate: 'constexpr ::(const &)'

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] no known conversion for argument 1 from 'int' to 'const &'

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] candidate: 'constexpr ::(
&&)'

D:/用户文件/桌面/C++/临时/未命名1.cpp 3 8 [说明] no known conversion for argument 1 from 'int' to '
&&'
(中间的两个数字是行和列)

  • 写回答

4条回答 默认 最新

  • 关注

    这命名, 我都怀疑能不能运行

    struct cmp{
        bool operator()(_ a,_ b) const
       {
            return a.t>b.t;
        }
    };
    
    本回答被专家选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 9月17日
  • 专家已采纳回答 9月9日
  • 修改了问题 9月1日
  • 创建了问题 9月1日

悬赏问题

  • ¥20 gitlab 中文路径,无法下载
  • ¥15 用动态规划算法均分纸牌
  • ¥30 udp socket,bind 0.0.0.0 ,如何自动选取用户访问的服务器IP来回复数据
  • ¥15 关于树的路径求解问题
  • ¥15 yolo在训练时候出现File "D:\yolo\yolov5-7.0\train.py"line 638,in <module>
  • ¥30 戴尔inspiron独显直连
  • ¥15 进行一项代码设计遇到问题
  • ¥15 Mutisim中关于74LS192N计数器芯片设计(计数器)
  • ¥50 fastadmin后台无法删除文件
  • ¥15 oracle查询Socket read timed out错误