C語言偵測一組身分證字號是否合法
不知道有沒有辦法用C來偵測呢?
2006-09-30 14:56:55 · 2 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 程式設計
#include
int test(char* sSource){
char* sUser[26]={"10","11","12","13","14","15","16","17","34","18","19","20","21","22","35","23","24","25","26","27","28","29","32","30","31","33"};
int n[10]={0,9,8,7,6,5,4,3,2,1};
int nScan=sUser[sSource[0]-'A'][0]-'0'+(sUser[sSource[0]-'A'][1]-'0')*9+(sSource[1]-'0')*8+(sSource[2]-'0')*7+(sSource[3]-'0')*6+
(sSource[4]-'0')*5+(sSource[5]-'0')*4+(sSource[6]-'0')*3+(sSource[7]-'0')*2+(sSource[8]-'0');
return n[nScan%10]==sSource[9]-'0';
}
int main(){
char s[11];
printf("請輸入身份證字號");
scanf("%10s",s);
if(test(s))
printf("很好..你是中華民國的人\n");
else
printf("你這個偷渡客\n");
}
2006-09-30 20:10:35 · answer #1 · answered by 士瑋 6 · 0⤊ 0⤋
是的,可以用 C 語言來檢測。點選以下網址如有看到亂碼,請點選「檢視」/「編碼」/「繁體中文」即可!http://www.geocities.com/mjshya/yahooKnowledge/c_id.c
2006-09-30 18:26:00 · answer #2 · answered by Big_John-tw 7 · 0⤊ 0⤋