未憧 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[])

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?