标签:put buffered 技术 com 文件 gen new line class
BufferedReader br=new BufferedReader(new FileReader("src/ch01/practice1/input.txt"));
PrintWriter pw=new PrintWriter("src/ch01/practice1/output.txt");
package ch01.practice1;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
//import java.util.Arrays;
//统计数字问题
public class PageNuber
{
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new FileReader("src/ch01/practice1/input.txt"));
String line=br.readLine();
if (null!=line)
{
int n=Integer.valueOf(line);
int[] arr= new int[10];
// Arrays.fill(arr,0);
// System.out.println(Arrays.toString(arr));
for (int i = 1; i < n+1; i++)
{
int div=i;
while(div>0)
{
arr[div%10]++;
div=div/10;
}
}
// System.out.println(Arrays.toString(arr));
PrintWriter pw=new PrintWriter("src/ch01/practice1/output.txt");
for (int i = 0; i < arr.length; i++)
{
pw.print(arr[i]+" ");
}
pw.close();
}
br.close();
}
}
标签:put buffered 技术 com 文件 gen new line class
原文地址:https://www.cnblogs.com/linkchen/p/12368214.html