未憧 2020-01-18 17:27 采纳率: 0%
浏览 240

在VC++6.0上编译运行没问题,在LintCode上编译出了问题,是哪里有问题?

//功能:输入两个整数,计算并输出它们的和
//语言:C++
#include<iostream>

using namespace std;

int main()
{
    int a,b,sum;
    cin >> a >> b;          //输入这两个数
    sum = a + b;
    cout << sum << endl;      //输出和
    return 0;
}

上面的代码在Visual C++6.0上运行没有任何问题,但在LintCode上面会出现如下错误警告,但我看不懂。

/code/Main.cpp: In function 'int main(int, char**)':
/code/Main.cpp:29:32: error: conflicting declaration of C function 'int main(int, char**)'
int main(int argc, char *argv[]) {
^
In file included from /code/Main.cpp:27:0:
/code/Solution.cpp:5:5: note: previous declaration 'int main()'
int main() 
^
/code/Main.cpp:58:9: error: 'Solution' was not declared in this scope
Solution solution;
^
/code/Main.cpp:60:15: error: 'solution' was not declared in this scope
ans = solution.aplusb(a, b);
^

哪里有问题呢?

  • 写回答

2条回答 默认 最新

  • bostonAlen 2020-01-18 22:26
    关注

    提示你main函数要有参数,写成int main(int argc, char *argv[])

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题