汤儿 2017-10-08 01:53 采纳率: 0%
浏览 5271

PTA上的错误分析,求大神指点(#>д<)ノ

求解求解:

最近在PTA上刷题,先从简单的开始吧。。写一道题时在DEV上编译没什么问题,但是在PTA上提交之后说编译有错误,不知道怎么回事。
代码如下:

#include
void printfN(int N);
int main()
{
int N;
printf("Inpute an positive number:");
scanf("%d",&N);
printfN(N);
return 0;
}
void printfN(int N)
{
if(N<1)
printf("Ivalid Input!\n");
else
{
for(int i=1;i<=N;i++)
printf("%d\n",i);
}

}

错误如是说:
a.c:16:5: error: redefinition of 'main'
int main()
^
a.c:4:5: note: previous definition of 'main' was here
int main ()
^
a.c: In function 'main':
a.c:8:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
a.c: In function 'main':
a.c:20:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
^

  • 写回答

3条回答 默认 最新

  • threenewbee 2017-10-08 02:27
    关注

    看下网站的说明,可能人家已经有main函数了,只让你编写一个解题的函数。要严格按照网站的要求做。

    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式