Posts Tagged ‘101(下)’

import java.io.*;
import java.util.*;
 
public class TestClassA {
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String filename = "record.txt";
		Random rdn = new Random();
		int num=100;
 
 
 
		try
		{
			FileWriter writer = new FileWriter(filename);
			PrintWriter pw = new PrintWriter(writer);
 
 
			for (int i=0; i<10000; i++)
			{
				num = rdn.nextInt()%101;
				if (num <0) num = -num + 100;
				else num = num + 100;
 
				System.out.printf("%d", num);System.out.println();
				pw.printf("%d", num); pw.println();
			}
 
			writer.close();
		}
		catch (FileNotFoundException fe)
		{
			System.out.printf(fe.getMessage());
			return;
		}
		catch (IOException ie)
		{
			System.out.printf(ie.getMessage());
			return;
		}
	}
 
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

import java.io.*;
import java.util.*;
public class TestClassB {
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String filename = "record.txt";
 
		try
		{
			FileReader reader = new FileReader(filename);
			BufferedReader br = new BufferedReader(reader);
 
			int count = 0;
			String line = br.readLine();
			while (line!=null && line.length() >0)
			{
				int num = Integer.parseInt(line);
				if (num < 125)
					count ++;
				System.out.printf("%d", num);System.out.println();
				line = br.readLine();
			}
			System.out.printf("<125 #=%d", count);System.out.println();
			reader.close();
		}
		catch (FileNotFoundException fe)
		{
			System.out.printf(fe.getMessage());
			return;
		}
		catch (IOException ie)
		{
			System.out.printf(ie.getMessage());
			return;
		}
	}
 
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

0523EBook

電子書素材的處理

電子書素材的處理

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

0522Prog

Java的數數

Java的數數

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

0522MI

第十章醫學資訊揭露和?私保護

第十章醫學資訊揭露和?私保護

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,