[問題] C矩陣問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev c++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
關於課本上面的範例,check a number for repeated digits
程式碼為
#include <stdbool.h>
#include <stdio.h>
int main (void) {
bool digit_seen[10] = {false};
int digit;
long n;
printf("enter number:");
scanf("%1d", &n);
while (n > 0) {
digit = n % 10;
if(digit_seen[digit])
break;
digit_seen[digit] = true;
n /= 10;
}
if (n > 0)
printf("repeated digit\n");
else
printf("no repeated digit\n")
return 0;
}
我完全照著打,可是結果是不管輸入甚麼數字進去,輸出的結果都是no repeated digit..orz
不知道問題出在哪邊,請板友幫幫忙qwq
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.37.225.24
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1397655350.A.0AF.html
→
04/16 21:50, , 1F
04/16 21:50, 1F
→
04/16 21:51, , 2F
04/16 21:51, 2F
推
04/16 21:52, , 3F
04/16 21:52, 3F
→
04/16 21:53, , 4F
04/16 21:53, 4F
推
04/16 21:59, , 5F
04/16 21:59, 5F
→
04/16 22:03, , 6F
04/16 22:03, 6F
→
04/16 22:35, , 7F
04/16 22:35, 7F
→
04/16 23:29, , 8F
04/16 23:29, 8F