玩玩小程序
来源:互联网 发布:java软件开发培训中心 编辑:程序博客网 时间:2024/05/21 08:25
一、L的3.41次方+40000L的1.56次方=21780889,帮我算出L
解决方案,正常算,确实不会算,采用无限趋近法,得到近似值,编程采用递归
import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.Console;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.util.ArrayList;import java.util.List;public class Io {public static void main(String args[]) throws Exception{new Io().operate(1, 1000, 1);}private void operate(double min,double max,double add){boolean bool = true;List<Double> list = new ArrayList<Double>();List<Double> listSub = new ArrayList<Double>();double sub = 0;for(double i=min;i<max;i+=add){list.add(i);double result = Math.pow(i, 3.41) + Math.pow(i, 1.56)*40000;if((sub = Math.abs(result-21780889)) < 0.001){bool = false;break;}else{listSub.add(sub);}}if(bool){int pos = 0;for(int j=0;j<listSub.size()-1;j++){pos = j;if(listSub.get(j)<listSub.get(j+1)){break;}}operate(list.get(pos-1), list.get(pos+1), add/10);}else{System.out.println("最终结果:"+list.get(list.size()-1)+" "+sub);}}}
二、
import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.Console;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.util.ArrayList;import java.util.List;public class Io {public static void main(String args[]) throws Exception{String path = "c:\\weibo.txt";String content = null;String account[];//read the txt;content = new Io().readTxt(path);// show all of the accounts on the screenaccount = content.split("#");for(int i=0,len=account.length;i<len;i++){System.out.println(account[i]);}// " " replace # and save in the flodercontent = content.replace("#", " ");new Io().writeTxt("c:\\chulihou.txt", content); //chulihou.txt这出题人也够NB嗒//delete the floderFile file = new File(path);file.delete();}private String readTxt(String path) throws Exception{StringBuffer string = new StringBuffer();String temp;BufferedReader in =new BufferedReader(new FileReader(path));while((temp = in.readLine()) != null){string.append(temp);}in.close();return string.toString();}private void writeTxt(String path, String content) throws Exception{FileWriter fw=new FileWriter( path ); BufferedWriter bw =new BufferedWriter(fw); bw.write( content );bw.flush();bw.close();fw.close();}}
- 玩玩小程序
- 一个小程序,大家可以来玩玩
- 业余写写WP程序玩玩
- 玩玩
- 玩玩
- 玩玩
- 玩玩
- 玩玩
- 玩玩
- 玩玩小爬虫——入门
- 玩玩小爬虫——试搭小架构
- 玩玩小爬虫——入门
- 玩玩小爬虫——试搭小架构
- 用栈写一个括号匹配的小代码玩玩
- 玩玩小爬虫——抓取动态页面
- 玩玩小爬虫——抓取动态页面
- WTL(2) - 写个简单的窗口程序玩玩
- 自己写个ping程序玩玩---附带抓包
- CentOS 6 IPv6 关闭方法
- 如何在 Windows Phone 8 的 LongListSelector 中显示分组列表内的数据
- Common functions for BASH SCRIPT
- 语句覆盖(Statement Coverage)|判定覆盖(Decision Coverage)|修订的条件/判定覆盖(Modified Condition/Decision Coverage)
- 如何在 Windows Phone 中创建自定义的不确定进度条
- 玩玩小程序
- 百度不收录怎么办?
- ubuntu12.04 没有/var/log/messages
- padding,margin,border的区别
- sqlite3自增key设定(创建自增字段)
- ZOJ Problem Set - 2348
- C++ 类成员函数重载(overload), 覆盖、重写(overrider), 隐藏(hidden)
- IO端口和IO内存的区别及分别使用的函数接口
- 大话设计模式简单总结