[問題] 為什麼他顯示不出正確的流水號??
這是小弟第一次在夾肉版發文
請多多指教
下面是個小習題
是一個產生10萬份身分證字號的程式
共十碼
第一碼為A-Z的大寫英文字母
第二碼為1 or 2 的阿拉伯數字
第三碼~第十碼為1~99999999的任意數字,若小於10000000者補0,例:3000---->00003000
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
char firstWord;
int secondNumber, otherNumbers;
for (int i=0; i<100000; i++) {
firstWord= (char) ((int)(Math.random()*100)%26+65);
secondNumber= (int)((Math.random()*100)%2)+1;
otherNumbers= (int)(Math.random()*10000000);
System.out.println(firstWord+ secondNumber+ otherNumbers);
//System.out.printf("%c%d%08d\n", firstWord, secondNumber, otherNumbers);
}
}
}
上面有兩行輸出的程式碼
我的問題在:我用未打註記的那行輸出無法輸出正確的身分證字號
用下面那行有註記的程式行則可以輸出正確的身分證字號
上面那行出現的問題是:1.沒有英文字母 2.數字長度不一
請問是為什麼呢?
又要如何修改才能像下面那行一樣??
--
咪嚕、撲撲
可愛~有時也很壞~
http://www.wretch.cc/album/album.php?id=b020306123&book=10
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.232.53.48
※ 編輯: liu2007 來自: 118.232.53.48 (08/16 20:26)
推
08/16 20:44, , 1F
08/16 20:44, 1F
→
08/16 21:10, , 2F
08/16 21:10, 2F
→
08/16 22:58, , 3F
08/16 22:58, 3F
推
08/17 06:41, , 4F
08/17 06:41, 4F