[問題] 程式碼看不懂..
自學刷leetcode中 看人家解答 但是一句不明
StringBuilder sb = new StringBuilder();
int carry = 0;
for (int i = a.Length - 1, j = b.Length - 1; i >= 0 || j >= 0; i--, j--){
int total= ((i >= 0 ? a[i] - '0' : 0) + (j >= 0 ? b[j] - '0' : 0)) + carry;
sb.Insert(0, total == 2 || total == 0 ? '0' : '1');
carry = total > 1 ? 1 : 0;
}
想請問其中的 a[i]-‘0’,b[j]-‘0’ 是什麼意思 google 很久查不到...
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.247.193.205
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1522284356.A.E21.html
→
03/29 08:47,
6年前
, 1F
03/29 08:47, 1F
推
03/29 09:54,
6年前
, 2F
03/29 09:54, 2F
→
03/29 11:32,
6年前
, 3F
03/29 11:32, 3F
推
04/04 10:45,
6年前
, 4F
04/04 10:45, 4F