Play with applets

Source: Internet
Author: User

1. The power of L is 3.41 + the power of 40000l is 1.56. Help me calculate the power of L

Solution, normal calculation, and true calculation, using the infinite approximation method to obtain an approximate value, programming using recursion

 

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 ("Final Result:" + list. get (list. size ()-1) + "" + sub );}}}

 

II,

 

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 this question is also enough for Nb // Delete the floderfile file = new file (PATH); file. delete ();} private string readtxt (string path) throws exception {Str Ingbuffer 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 ();}}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.