課程
/后端開發
/C
/C語言入門
這樣寫不會循環,結果為0????為什么呀
2015-08-12
源自:C語言入門 6-2
正在回答
#include <stdio.h>int main(){??? int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};??? int i=-1;??? ??? while(i<9)??? {??????? i++;??printf("%d\n",arr[i]);??? }??? ??? //補全代碼實現對數組arr的遍歷??? //可以采用你自己喜歡的循環結果? ??? return 0;????? ??? }
大哥,越界了,循環后,i=10,你引用a[10]是不正確的,最多只有a[9]
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
1 回答while循環
3 回答while 循環
4 回答while循環
2 回答while循環
3 回答while循環
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-10-25
#include <stdio.h>
int main()
{
??? int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
??? int i=-1;
???
??? while(i<9)
??? {
??????? i++;
??printf("%d\n",arr[i]);
??? }
???
??? //補全代碼實現對數組arr的遍歷
??? //可以采用你自己喜歡的循環結果
?
??? return 0;
?????
???
}
2015-08-12
大哥,越界了,循環后,i=10,你引用a[10]是不正確的,最多只有a[9]