gpt4 book ai didi

C++ 错误 : expected primary-expression before ‘int’

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:14:55 25 4
gpt4 key购买 nike

这部分代码中的每个整数都出现此错误;

if(choice==2) {
inssort(int *a, int numLines);
}
if(choice==3) {
bubblesort(int *a, int numLines);
}
if(choice==4) {
mergesort(int *a, int numLines);
}
if(choice==5) {
radixsort(int *a, int numLines);
}
if(choice==6) {
return 0;
}

那是我在 main 中调用函数的地方。如果您想知道我正在编写一个小程序,让用户可以在 4 种不同类型的排序算法之间对列表进行选择。

如有任何帮助,我们将不胜感激。

最佳答案

当您调用 函数时,您不能使用声明类型。仅当您声明时才需要它们:

if(choice==2)
{
inssort(a, numLines);
}
if(choice==3)
{
bubblesort(a, numLines);
}
if(choice==4)
{
mergesort(a, numLines);
}
if(choice==5)
{
radixsort(a, numLines);
}
if(choice==6)
{
return 0;
}

关于C++ 错误 : expected primary-expression before ‘int’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8117282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com