看板 C_and_CPP 關於我們 聯絡資訊
請問有辦法宣告陣列大小後 直接一次輸入所有的數然後存進陣列嗎 int i[6] 5 7 3 1 2 4 然後按enter輸入進陣列 目前只想到用迴圈一個一個輸入 一時之間翻書找不到 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.195.60.48
james732:C還是C++? 11/21 21:30
james732:以C++來說,這樣就行:http://nopaste.csie.org/92e8d 11/21 21:35
james732:執行結果:http://ppt.cc/x7T2 11/21 21:35
stupid0319:樓上,原PO應該是不想用迴圈吧?? 11/21 21:36
james732:這個嘛,那改用遞迴好了 http://nopaste.csie.org/3a431 11/21 21:39
wfgh:先存進字串,再去分割那個字串 11/21 21:39
chrisdar:http://nopaste.csie.org/6ae07 11/21 21:53
BSpowerx:cin >> i[0] >> i[1] >> i[2] >> ...(ry 11/21 21:55
curist:..那..scanf("%d %d %d %d %d %d", &i[0],&i[1]... 11/21 22:46
Yshuan:每個element配置value 複雜度明顯是Theta(N) 用迴圈不好嗎? 11/21 23:41