poj1454
简单题
java输出可以使用System.out.format();
这个的使用方法与printf();相同。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
public static void main(String[] args)
{
Scanner cin = new Scanner(new BufferedInputStream(System.in));
int a;
while (cin.hasNext())
{
a = cin.nextInt();
if (a == 0)
break;
BigInteger x = new BigInteger("1");
for (int i = 2; i <= a; i++)
x = x.multiply(BigInteger.valueOf(i));
String st = x.toString();
int[] ans = new int[10];
for (int i = 0; i < 10; i++)
ans[i] = 0;
int len = st.length();
for (int i = 0; i < len; i++)
ans[(int)(st.charAt(i) - '0')]++;
System.out.println(a + "! --");
System.out.format(" (%d)%5d", 0, ans[0]);
for (int i = 1; i < 5; i++)
System.out.format(" (%d)%5d", i, ans[i]);
System.out.println("");
System.out.format(" (%d)%5d", 5, ans[5]);
for (int i = 6; i < 10; i++)
System.out.format(" (%d)%5d", i, ans[i]);
System.out.println("");
}
}
}