你好,import java.io.FileReader;
import java.io.BufferedReader;
/**
* @(#)Test.java
*
*
* @author
* @version 1.00 2007/6/21
*/
public class Test {
/**
* Creates a new instance of Test
.
*/
public Test() {
}
public void method1() throws Exception
{
BufferedReader br = new BufferedReader(new FileReader("1.ini"));
String str1 = br.readLine();
String str2 = br.readLine();
int a = Integer.valueOf(str1);
int b = Integer.valueOf(str2);
int count=0;
while(a<=b)
{
if(a%3 == 0&& a%7 ==0)
count++;
a++;
}
System.out.println(count);
}
public void method2() throws Exception
{
BufferedReader br = new BufferedReader(new FileReader("2.ini"));
String str1 = br.readLine();
String str2 = br.readLine();
int b = Integer.valueOf(str2);
int count = 0;
for(int a = Integer.valueOf(str1);a<=b;a++)
{
if(isPrime(a)==true)
count++;
}
System.out.println(count);
}
private static boolean isPrime(int n)
{
for(int i=2;i
{
if(n%i==0)
return false;
}
return true;
}
public void method3() throws Exception
{
BufferedReader br = new BufferedReader(new FileReader("3.ini"));
String str1 = br.readLine();
int a = Integer.valueOf(str1);
int account = add(a);
System.out.println(account);
}
private int add(int parameter)
{
int data[] = new int[parameter];
int account=0;
if(parameter==1)
return 1;
if(parameter==2)
return 2;
if(parameter==0)
return 0;
if(parameter>2)
{
for(int i=0;i
{
data [0] = 1;
data [1] = 1;
data[i+2] = data[i]+data[i+1];
}
for(int i=0;i
{
account+=data[i];
}
}
return account;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
// TODO code application logic here
Test t = new Test();
t.method1();
t.method2();
t.method3();
}
}
以上都是a
没时间了.等有时间给你补全. 2196希望对你有帮助!