首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

每日一道算法_6_I Think I Need a Houseboat

2013-10-10 
每天一道算法_6_I Think I Need a Houseboat今天的题目是I Think I Need a Houseboat如下:21.0 1.025.0 0.

每天一道算法_6_I Think I Need a Houseboat

今天的题目是I Think I Need a Houseboat

如下:

每日一道算法_6_I Think I Need a Houseboat

21.0 1.025.0 0.0

Property 1: This property will begin eroding in year 1.Property 2: This property will begin eroding in year 20.END OF OUTPUT.

import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class IThinkINeedaHouseboat {public static void main(String args[]){double PI = 3.1415926;int year = 1;float area = 0;int year_count = 0;Scanner in = new Scanner(System.in);int all = in.nextInt();int count = all * 2;List<Float> list = new ArrayList<Float>();while(count > 0){count--;list.add(in.nextFloat());}for(int i = 0; i<list.size(); i = i + 2){year_count ++;area = (float) (PI*(list.get(i) * list.get(i) + list.get(i + 1) * list.get(i + 1))/2);for(year = 1; year * 50 < area; year ++){}System.out.println("Property "+ year_count + ": This property will begin eroding in year " + year + ".");}System.out.println("END OF OUTPUT.");}}


 

作者:jason0539

微博:http://weibo.com/2553717707

博客:http://blog.csdn.net/jason0539(转载请说明出处)

 

热点排行