1 , 几道java 初学题第5题public class hen{ public static void main(String args[]){for(int i=0;i<=20;i++){for(int j=0;j<=33;j++){if((5*i+3*j+(100-i-j)/3==100)&&((100-i-j)%3==0)){System.out.println("母鸡:"+i);System.out.println("公鸡:"+j);int temp=100-i-j;System.out.println("小鸡:"+temp);System.out.println();}}} }}
2,最基础的JAVA题乱打`package test;public class Arr{ /*** @param args*/ public static void main(String[] args) {// TODO Auto-generated method stubint arr[]=new int[20];arr[0]=0;arr[1]=1;for(int i=2;i<20;i++){arr[i]=arr[i-1]+arr[i-2];}for(int i=0;i<20;i++){System.out.print(" "+arr[i]);} }}输出结果:0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181
3,java 初学者题目第一题: (输入每个值的时候都按回车,这个值中夹杂"stop"列入停止范围)具体程序如下: import java.util.Scanner; public class WhenStopOthers1 public static void main(String[] args) // TODO Auto-generated method stubScanner input = new Scanner(System.in);System.out.println("请输入:");String str = input.next();while (!str.equals("stop"))System.out.println("请继续输入,直到输入stop为止:");str = input.next();}System.out.println("输入结束.");} } /** *********************我是分隔线******************* **/第二题: (对已经赋值的一维数组进行逆序输出) 程序如下:public class BackOutpublic static void main(String[] args)String[] s =for(int i = s.length - 1; i >= 0 ; i--) System.out.print(s[i]);if(i == 0) System.out.println();}}} }【java基础入门试题,几道java 初学题】
4 , 3道JAVA入门题呵呵 百度HI我,我教你 。import java.io.*;import java.util.*;public class test10 public static void main(string[] args)solve(); } public static void solve()string input = null;string read = null;stringbuilder str = null;file file = null;filewriter writer = null;filereader reader = null;filewriter other = null;bufferedwriter out = null;bufferedreader in = null;char[] buf = null;tryfile = new file("output1.txt");writer = new filewriter(file,true);out = new bufferedwriter(writer);reader = new filereader(file);in = new bufferedreader(reader);other =new filewriter("otherfile.txt",true);}catch (ioexception e)e.printstacktrace();}scanner scanner = new scanner(system.in);system.out.print("请输入(输入end结束):");//说是输入文字,输入英文退出不会冲突吧?while(!(input = scanner.nextline()).equalsignorecase("end"))tryout.write(input);out.newline();}catch (ioexception e)e.printstacktrace();}}tryout.close();writer.close();}catch (ioexception e)e.printstacktrace();}system.out.println("读取的内容为:");buf = new char[(int)file.length()];trywhile( (read = in.readline()) != null)str = new stringbuilder(read);str = str.reverse();system.out.println(str);other.write(str.tostring());}}catch (ioexception e)e.printstacktrace();}finallytrywriter.close();}catch (ioexception e)e.printstacktrace();}}}}5,几道JAVA初级题目高手帮忙做下谢谢第1题int sum = 0;for(int i = 1; i <= 10; i++)int jsum = 1;for(int j = 1; j <= i; j++)jsum *= j;}sum += jsum;}System.out.println(sum); 第2题int sum = 0;for(int i = 2; i < 50; i++)boolean flag = true;for(int j = 2; j < i; j++)if(i % j == 0)flag = false;break;}}if(flag)sum += i;}}System.out.println(sum);第3题Random r = new Random();int[] a = new int[20];for(int i = 0; i < a.length; i++)a[i] = r.nextInt(51) + 50;}int max = a[0], index = 0;for(int i = 1; i < a.length; i++)if(max < a[i])max = a[i];index = i;}}System.out.println("最大数为" + max + ", 产生时的序号为:" + index);第4题 import java.util.Random; import java.util.Arrays;public class Testpublic static void main(String[] args)int[] a = new int[10];Random r = new Random();for(int i = 0; i < a.length; i++)a[i] = r.nextInt(91) + 10;//10到100之间的随机数,包含100}Arrays.sort(a);String result = Arrays.toString(a);System.out.println(result);} }第5题// 长方形周长public static double fun1(double w, double h)return 2 * (w + h);}// 长方形面积public static double fun2(double w, double h)return w * h;}// 正方形周长public static double fun3(double s)return 4 * s;}// 正方形面积public static double fun4(double s)return s * s;}// 圆周长public static double fun5(double r)return 2 * Math.PI * r;}// 圆面积public static double fun6(double r)return Math.PI * r * r;}你不就是高手嘛…… 。自己做
推荐阅读
- printf,printf是什么意思
- using 翻译,using是什么意思
- 元气骑士破解版235下载,元气骑士有狼人精灵120的破解版
- 苹果平板建议买哪款吃鸡,求一个可以流畅吃鸡的平板电脑
- eclipse写c语言,eclipse也可以编辑c语言吗
- python线程锁不起作用,python为什么aptitute不能用
- 微信自己小程序编程,微信小程序自己怎么编辑
- 超级玛丽编程制作过程图片,python怎么做超级马里奥
- 安卓开发用的软件,android常用开发工具有哪些