准备跟着陈越老师的《数据结构》公开课,学习一遍基础的数据结构知识,同时重点把PTA上的作业题做一做。
另外,我打算学公开课的同时跟着《算法笔记》把书过一遍,上面的题全部刷一遍。
LeetCode上的题目也会刷一些,并且打算每一道题都用C和Python两种语言来做。
打算把做过的题都在优快云上做好记录,也便于自己之后再回顾。
这是做的第一道题,很简单,是课上讲过的,打算预热一下。不过还是踩了坑,出现了一些问题。
这是第一次提交的代码,测试全部通不过。报错里出现了:
a.c: In function ‘main’:
a.c:23:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^~~~~~~~~~~~~~~
a.c:26:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^~~~~~~~~~~~~~~~~~
我还以为是scanf的返回值的问题就在scanf前加上了(void),还是通不过(因为那只是warning...无所谓的)
改成:if(scanf("%d", &n)==1); if(