[問題] A[x++] = --x
看板C_and_CPP (C/C++)作者CaliforCat (Cal)時間3年前 (2021/08/31 12:08)推噓29(31推 2噓 146→)留言179則, 24人參與討論串1/3 (看更多)
開發平台(Platform): (Ex: Win10, Linux, ...)
Win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
遇到題目問這題的輸出,我的想法是先將x=x-1
後續就不太知道該怎麼判斷,而且用兩個ide跑出的結果不同
int main()
{
int A[3] = {0, 0, 0};
int x = 1;
A[x++] = --x;
printf("A[0]=%d, A[1]=%d, A[2]=%d", A[0], A[1], A[2]);
}
餵入的資料(Input):
無
預期的正確結果(Expected Output):
用code block跑出來是
A[0]=1, A[1]=0, A[2]=0
https://i.imgur.com/3UGzFqf.jpg
用線上ide codechef跑出來是
A[0]=0, A[1]=1, A[2]=0
https://i.imgur.com/oYd3YFB.jpg
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
已於上述列出
麻煩各位大大 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.136.255.127 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1630382935.A.E4F.html
→
08/31 12:12,
3年前
, 1F
08/31 12:12, 1F
推
08/31 12:39,
3年前
, 2F
08/31 12:39, 2F
噓
08/31 14:02,
3年前
, 3F
08/31 14:02, 3F
→
08/31 14:02,
3年前
, 4F
08/31 14:02, 4F
題目不是我出的啊大哥,遇到我也很困擾,不知道怎麼解
推
08/31 14:24,
3年前
, 5F
08/31 14:24, 5F
→
08/31 14:24,
3年前
, 6F
08/31 14:24, 6F
這種真的是各種考試很愛考
→
08/31 14:51,
3年前
, 7F
08/31 14:51, 7F
※ 編輯: CaliforCat (114.136.255.127 臺灣), 08/31/2021 16:33:27
噓
08/31 18:09,
3年前
, 8F
08/31 18:09, 8F
推
08/31 20:31,
3年前
, 9F
08/31 20:31, 9F
推
09/02 12:47,
3年前
, 10F
09/02 12:47, 10F
→
09/02 12:47,
3年前
, 11F
09/02 12:47, 11F
→
09/02 12:48,
3年前
, 12F
09/02 12:48, 12F
→
09/02 12:48,
3年前
, 13F
09/02 12:48, 13F
→
09/02 14:40,
3年前
, 14F
09/02 14:40, 14F
→
09/02 14:40,
3年前
, 15F
09/02 14:40, 15F
→
09/02 14:41,
3年前
, 16F
09/02 14:41, 16F
→
09/02 14:42,
3年前
, 17F
09/02 14:42, 17F
→
09/03 01:03,
3年前
, 18F
09/03 01:03, 18F
→
09/03 04:50,
3年前
, 19F
09/03 04:50, 19F
推
09/03 12:56,
3年前
, 20F
09/03 12:56, 20F
→
09/03 12:57,
3年前
, 21F
09/03 12:57, 21F
→
09/03 13:43,
3年前
, 22F
09/03 13:43, 22F
→
09/03 13:45,
3年前
, 23F
09/03 13:45, 23F
→
09/03 13:46,
3年前
, 24F
09/03 13:46, 24F
推
09/05 17:32, , 25F
09/05 17:32, 25F
→
09/06 00:07, , 26F
09/06 00:07, 26F
推
09/06 11:18, , 27F
09/06 11:18, 27F
推
09/07 06:34, , 28F
09/07 06:34, 28F
推
09/07 11:48, , 29F
09/07 11:48, 29F
推
09/08 02:32, , 30F
09/08 02:32, 30F
→
09/08 17:16, , 31F
09/08 17:16, 31F
推
09/08 17:23, , 32F
09/08 17:23, 32F
→
09/08 17:23, , 33F
09/08 17:23, 33F
→
09/08 17:23, , 34F
09/08 17:23, 34F
推
09/09 07:33, , 35F
09/09 07:33, 35F
→
09/09 07:33, , 36F
09/09 07:33, 36F
還有 103 則推文
→
09/12 22:57, , 140F
09/12 22:57, 140F
→
09/12 22:57, , 141F
09/12 22:57, 141F
→
09/12 22:57, , 142F
09/12 22:57, 142F
推
09/13 10:58, , 143F
09/13 10:58, 143F
→
09/13 10:58, , 144F
09/13 10:58, 144F
→
09/13 10:58, , 145F
09/13 10:58, 145F
→
09/13 10:58, , 146F
09/13 10:58, 146F
→
09/13 10:58, , 147F
09/13 10:58, 147F
→
09/13 10:58, , 148F
09/13 10:58, 148F
→
09/13 10:58, , 149F
09/13 10:58, 149F
→
09/13 10:58, , 150F
09/13 10:58, 150F
→
09/13 10:58, , 151F
09/13 10:58, 151F
→
09/13 10:58, , 152F
09/13 10:58, 152F
→
09/13 10:58, , 153F
09/13 10:58, 153F
→
09/13 10:58, , 154F
09/13 10:58, 154F
→
09/13 10:58, , 155F
09/13 10:58, 155F
→
09/13 10:58, , 156F
09/13 10:58, 156F
→
09/13 10:58, , 157F
09/13 10:58, 157F
→
09/13 10:58, , 158F
09/13 10:58, 158F
→
09/13 10:58, , 159F
09/13 10:58, 159F
→
09/13 10:58, , 160F
09/13 10:58, 160F
→
09/13 10:58, , 161F
09/13 10:58, 161F
→
09/13 10:58, , 162F
09/13 10:58, 162F
推
09/13 11:05, , 163F
09/13 11:05, 163F
→
09/13 11:06, , 164F
09/13 11:06, 164F
→
09/13 11:07, , 165F
09/13 11:07, 165F
→
09/13 11:08, , 166F
09/13 11:08, 166F
→
09/13 11:09, , 167F
09/13 11:09, 167F
→
09/13 11:10, , 168F
09/13 11:10, 168F
→
09/13 11:10, , 169F
09/13 11:10, 169F
→
09/13 11:11, , 170F
09/13 11:11, 170F
→
09/13 11:12, , 171F
09/13 11:12, 171F
→
09/13 11:12, , 172F
09/13 11:12, 172F
推
09/13 21:23, , 173F
09/13 21:23, 173F
→
09/13 21:27, , 174F
09/13 21:27, 174F
推
09/13 22:23, , 175F
09/13 22:23, 175F
→
09/13 22:23, , 176F
09/13 22:23, 176F
→
09/13 22:24, , 177F
09/13 22:24, 177F
推
09/13 22:29, , 178F
09/13 22:29, 178F
推
09/14 07:18, , 179F
09/14 07:18, 179F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章