[問題] 寫程式的習慣
最近跟同學合作寫一個專案
發現有些寫程式的習慣不一樣
1.
for(;;)
{
int a = ***** ;
}
2. int a = 0;
for(;;){
a = *****;
}
1 是我的寫法 我喜歡 左右括號在同條線上 這樣要檢查方便多了
宣告放在 {}內 這樣對我來說 可讀性大大提升
而且也不怕別個地方再宣告a
ps 所以我超愛 2003 每個 {} 都可以縮起來
可惜 2005 只有函式的 {} 才能縮
2 是我同學的習慣
因為一般書上為了減少行數 都會把左大括號放在最後面
而且他認為宣告放外面 這樣程式跑比較快
不知道大家的習慣呢??? 還是有其他好習慣要養成呢
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.84
推
09/23 19:12, , 1F
09/23 19:12, 1F
→
09/23 19:14, , 2F
09/23 19:14, 2F
→
09/23 19:14, , 3F
09/23 19:14, 3F
→
09/23 19:15, , 4F
09/23 19:15, 4F
推
09/23 19:29, , 5F
09/23 19:29, 5F
推
09/23 19:38, , 6F
09/23 19:38, 6F
推
09/23 19:50, , 7F
09/23 19:50, 7F
→
09/23 19:50, , 8F
09/23 19:50, 8F
→
09/23 19:56, , 9F
09/23 19:56, 9F
推
09/23 20:03, , 10F
09/23 20:03, 10F
→
09/23 20:04, , 11F
09/23 20:04, 11F
推
09/23 20:23, , 12F
09/23 20:23, 12F
推
09/23 20:59, , 13F
09/23 20:59, 13F
→
09/23 20:59, , 14F
09/23 20:59, 14F
→
09/23 21:00, , 15F
09/23 21:00, 15F
→
09/23 21:27, , 16F
09/23 21:27, 16F
推
09/23 21:50, , 17F
09/23 21:50, 17F
推
09/23 22:11, , 18F
09/23 22:11, 18F
推
09/23 22:29, , 19F
09/23 22:29, 19F
→
09/23 22:42, , 20F
09/23 22:42, 20F
推
09/24 00:09, , 21F
09/24 00:09, 21F
推
09/24 00:22, , 22F
09/24 00:22, 22F
推
09/24 00:40, , 23F
09/24 00:40, 23F
→
09/24 00:41, , 24F
09/24 00:41, 24F
→
09/24 01:08, , 25F
09/24 01:08, 25F
推
09/24 01:41, , 26F
09/24 01:41, 26F
→
09/24 01:42, , 27F
09/24 01:42, 27F
推
09/24 09:18, , 28F
09/24 09:18, 28F
推
09/24 10:50, , 29F
09/24 10:50, 29F
推
09/24 11:34, , 30F
09/24 11:34, 30F
推
09/24 12:27, , 31F
09/24 12:27, 31F
→
09/24 12:28, , 32F
09/24 12:28, 32F
推
09/24 13:06, , 33F
09/24 13:06, 33F
推
09/24 13:18, , 34F
09/24 13:18, 34F
→
09/24 14:44, , 35F
09/24 14:44, 35F
推
09/24 15:42, , 36F
09/24 15:42, 36F
推
09/24 19:56, , 37F
09/24 19:56, 37F
推
09/25 16:43, , 38F
09/25 16:43, 38F
推
09/25 18:28, , 39F
09/25 18:28, 39F
推
09/26 15:32, , 40F
09/26 15:32, 40F
→
10/24 02:53, , 41F
10/24 02:53, 41F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章