bekitty

我不会讲大道理,可我心里有一杆秤。 我看这个世界很苛刻,可我的心里很宽容。 我不需要权力与利益,可是我需要公平与正义。 我始终知道正道难行,可不得不行。

导航

Poj1005- 没啥新意,重温数组

Posted on 2013-10-09 12:07  bekitty  阅读(170)  评论(0编辑  收藏  举报
package Poj1005_map;

 

import java.util.Scanner;

 

public class Poj1005 {

 

private static final float PI = (float) 3.1415926;

public static void main(String[] args) throws Exception{

// TODO Auto-generated method stub

 

Scanner cin = new Scanner(System.in);

int setnum = cin.nextInt();

float[] x; 

float[] y;

x = new float[setnum];

y = new float[setnum];

for(int i=0;i<setnum;i++){

x[i] = (float) cin.nextFloat();

y[i] = (float) cin.nextFloat();

}

for(int j=0;j<setnum;j++)

System.out.println("Property " + (j+1) + ": " + "This property will begin eroding in year " + caculateYear(x[j],y[j]) + ".");

System.out.println("END OF OUTPUT.");

 

}

public static int caculateYear(float x, float y){

float dis = 0,r = 0;

int year=1;

dis = (float) Math.sqrt(x*x+y*y);

while(r<dis){

r = (float) Math.sqrt(50*2*year/PI);

year++;

}

return year-1;

}

 

}