- 1、本文档共15页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
新手需要框架(Beginners need frames)
新手需要框架(Beginners need frames)
1. write a method to print a 99 multiplication table with a for loop
*//** / * *
* 99 print multiplication table
* /
Public, void, nineNineMulitTable () {
For (int i = 1, j = 1; J 9; i++) {
System.out.print (i+ * *, +j+ = = +i*j+);
If (i==j) {
I=0;
J++;
System.out.println ();
}
}
}
2., given how a java.util.Date object is converted into 2007-3-22 20:23:22 format string
*//** / * *
* convert a date into a string in a fixed format
* @param date
* @return str
* /
Public String date2FormatStr (Date date)
{
SimpleDateFormat SDF = new SimpleDateFormat (yyyy-MM-dd HH:mm:ss);
String STR = sdf.format (date);
Return str;
}
3. write a method that can determine whether any integer is a prime number
*//** / * *
* to determine whether any integer is a prime number
* @param num
* @return Boolean
* /
Public Boolean isPrimeNumber (int Num)
{
For (int i = 2; I Math.sqrt (Num); i++) {
If (num%i==0)
{
Return false;
}
}
Return true;
}
4. write a method, enter any integer, return its factorial
*//** / * *
* obtain the factorial of any integer
*@param n
*@returnn!
* /
Public int factorial (int Num)
{
/ / recursive
If (Num = 1)
{
Return 1;
}
Return num*factorial (num-1);
}
5. write a method, using two point search method to determine any integer in any integer array, whether it exists, if it exists, returns its index position in the array, there is no return -1
*//** / * *
* two to find the position of a particular integer in an integer array (recursive)
*@param dataset
*@param data
*@param beginIndex
*@param endIndex
*@return index
* /
Public, int, binarySearch (int[], dataset, int, data, int, beginIndex, int, endIndex) {
Int midIndex = (beginIndex+endIndex) /2;
If the search number / / than the start index data is smaller than to end or indexed book to, or start searching the index value is greater than the end of the index return -1 not found
If (data, dataset[beginIndex]||datadataset[endIndex]||beginIndexendIndex) {
Return -1;
}
If (data, dataset[midInde
您可能关注的文档
- 投资者集中获利回吐使欧元涨势告一段落(The concentration of profit taking by investors has brought the euro rally to an end).doc
- 投资项目管理师(Investment Project Manager).doc
- 投资银行与商业银行的区别 英语(The difference between investment bank and Commercial Bank).doc
- 抑制石油用量和中国的可持续发展1(Curb oil consumption and China's sustainable development 1).doc
- 把你打叉-藤井树(Put your fork - tengjingshu).doc
- 折扣店、(Discount Store、).doc
- 投资学(Investment).doc
- 抛物线的几何性质(Geometric properties of parabola).doc
- 抗洪复电,守护光明(Flood restoration, guardian light).doc
- 抢夺式招商策划(Snatch investment planning).doc
文档评论(0)