/**
* Description: 写打印从0~9之间选出2个数的所有组合
* @author Mr Lv
* @date 2011-11-16
*/
public class lzwCode{
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
String str = String.valueOf(i); //返回字符串的形式
for (int j = str.length(); j < 2; j++) {
str = "0" + str;
}
System.out.print(str+",");
}
}
}
控制台结果:
php 实现该功能:
<?php
for ($i = 0; $i < 100; $i++) {
for ($j = strlen($i); $j < 2; $j++) {
$i = "0".$i;
}
echo $i.",";
}
?>