




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1. 百鸡问题;/* * (#)baiji.java * * * author * version 1.00 2010/3/17 */public class baiji /* * Creates a new instance of baiji. */ public baiji() /* * param args the command line arguments */ public static void main(String args) / TODO code application logic here System.out.println( 百鸡问题); int x; int y; int z; for(x=1;x=100;x+) for(y=1;y=100;y+) for(z=1;z=100;z+) if(x+y+z=100)&(5*x+3*y+z/3.0=100) System.out.print(the number of cocks is+x+;); System.out.print(the number of hens is+y+;); System.out.print(the number of chicks is+z+.); System.out.println(); 2.求自然对数e;/* * (#)E.java 1.0 10/03/17 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.e;import java.awt.*;import java.awt.event.*;class E extends Frame public E() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) double e = 1.0; double t = 1.0; for (int i = 1; i 0; i-) e = (e + 1.0) / i; e+; System.out.println(e); */ 3.求圆周率pi;/* * (#)pi.java * * * author * version 1.00 2010/3/18 */public class pi /* * Creates a new instance of pi. */ public pi() /* * param args the command line arguments */ public static void main(String args) / TODO code application logic here double i; double s; double Pi; int sign=1; i=1; s=0; Pi=0; while (i=1000000) s=1/i; i=i + 2; s=s*sign; sign=(-1)*sign; Pi=Pi+s; Pi=Pi*4; System.out.println(Pi=+Pi); 4.输入字符串;/* * (#)app3_3.java * * * author * version 1.00 2010/3/18 */ /app3_3.javaimport java.io.*;public class app3_3 /* * Creates a new instance of app3_3. */ public app3_3() /* * param args the command line arguments */ public static void main(String args) throws IOException / TODO code application logic here BufferedReader buf; String str; buf=new BufferedReader(new InputStreamReader(System.in); System.out.print(请输入字符串:); str=buf.readLine(); System.out.println(您输入的字符串是:+str); 5. .教材P51页的逻辑运算符的练习;/* * (#)App3_6.java 1.0 02/07/25 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.app3_6;import java.awt.*;import java.awt.event.*;class App3_6 extends Frame public App3_6() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) System.out.println(Starting App3_6.);App3_6 mainFrame = new App3_6();mainFrame.setSize(400, 400);mainFrame.setTitle(App3_6);mainFrame.setVisible(true);int a=25,b=7;boolean x=ab;System.out.println(a5;System.out.println(xy=+(xy);if(e!=0&b5) System.out.println(a/f=+a/f);else System.out.println(f=+f);6.教材P61页if语句的运用;app4_1/* * (#)App4_1.java 1.0 02/07/25 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.app4_1;import java.awt.*;import java.awt.event.*;class App4_1 extends Frame public App4_1() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) System.out.println(Starting App4_1.);App4_1 mainFrame = new App4_1();mainFrame.setSize(400, 400);mainFrame.setTitle(App4_1);mainFrame.setVisible(true);int a=1,b=2,c=3,max,min;if(ab) max=a;else max=b;if(cmax)max=c;System.out.println(Max=+max);min=ab?a:b;min=cmin?c:min;System.out.println(Min=+min); 7.教材P66页求1+2+3+4.+n之和;/* * (#)App4_6.java 1.0 02/07/25 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.app4_6;import java.io.*;import java.awt.*;import java.awt.event.*;class App4_6 extends Frame public App4_6() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args)throws IOException System.out.println(Starting App4_6.);App4_6 mainFrame = new App4_6();mainFrame.setSize(400, 400);mainFrame.setTitle(App4_6);mainFrame.setVisible(true);int n,i=1,sum=0;String str;BufferedReader buf;buf=new BufferedReader(new InputStreamReader(System.in);doSystem.out.print(输入正整数:);str=buf.readLine();n=Integer.parseInt(str);while(n=0);while(i=n) sum+=i+; System.out.println(1+2+.+n+=+sum);8.教材P69页利用for循环求1+2+.10之和;/* * (#)App4_9.java 1.0 02/07/25 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.app4_9;import java.awt.*;import java.awt.event.*;class App4_9 extends Frame public App4_9() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) System.out.println(Starting App4_9.);App4_9 mainFrame = new App4_9();mainFrame.setSize(400, 400);mainFrame.setTitle(App4_9);mainFrame.setVisible(true);int i,n=10,s=0;for(i=1;i1;i-)s+=i;System.out.print(i+);System.out.println(i+=+(s+i);9.冒泡排序;/* * (#)Maopao.java 1.0 10/03/26 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.maopao;import java.awt.*;import java.awt.event.*;class Maopao extends Frame public Maopao() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) System.out.println(Starting Maopao.);Maopao mainFrame = new Maopao();mainFrame.setSize(400, 400);mainFrame.setTitle(Maopao);mainFrame.setVisible(true);int a=new int13, 69 ,52, 35 ,27, 9 ,15 ,56 ,32 ,17; int cont=0; System.out.print(从大到小:); for(int i=0;ia.length;i+) for(int j=0;ja.length-i-1;j+) if(ajaj+1) cont=aj; aj=aj+1; aj+1=cont; for(int i=0;ia.length;i+) System.out.print(ai+ ); 10.九九乘法表;/* * (#)jiujiu.java * * * author * version 1.00 2010/4/6 */public class jiujiu /* * Creates a new instance of jiujiu. */ public jiujiu() /* * param args the command line arguments */ public static void main(String args) / TODO code application logic here int m,n; System.out.println( 九九乘法表); for(m=1;m=9;m+) for(n=1;n=m;n+) System.out.print(n+*+m+=+(n*m)+ ); System.out.println(); 11.牛顿迭代法解一元高次方程;12.两个矩阵相乘的;/* * (#)juzhen.java * * * author * version 1.00 2010/3/25 */2个矩阵相乘public class juzhen static int a; static int b; /* * Creates a new instance of juzhen. */ public juzhen() /* * param args the command line arguments */ public static void main(String args) / TODO code application logic here int i,j,k,t; int a=3,-1,0,3,1,4,2,1; int b=1,-2,3,2,1,0; int x=a.length; int y=b0.length; int z=b.length; int r=new intxy; for(i=0;ix;i+) for(j=0;jy;j+) rij=0; for(k=0;kz;k+) rij+=aik*bkj; for(i=0;ir.length;i+) for(j=0;j edcba;/* * (#)reverse.java 1.0 09/07/06 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.reverse;import java.awt.*;import java.awt.event.*;import java.io.*;import java.lang.String;class reverse extends Frame public reverse() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args)throws IOException System.out.print(请输入字符串:); BufferedReader br = new BufferedReader(new InputStreamReader(System.in); String str = br.readLine(); char a = str.toCharArray(); System.out.print(字符串倒置的结果是:); for (int i = a.length - 1; i = 0; i-) System.out.print(ai+ ); System.out.println(); 14. 程序设计代码.doc-程序设计代码/* * (#)wenjian.java 1.0 09/07/06 * * You can modify the template of this file in the * directory .JCreatorTemplatesTemplate_1Project_Name.java * * You can also create your own project template by making a new * folder in the directory .JCreatorTemplate. Use the other * templates as examples. * */package myprojects.wenjian;import java.awt.*;import java.awt.event.*;import java.io.*;class wenjian extends Frame public wenjian() addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) dispose();System.exit(0););public static void main(String args) throws IOExceptionSystem.out.print(请输入文件全名:);BufferedReader br = new BufferedReader(new InputStreamReader(System.in); String str = br.readLine(); str=str.substring(0,str.lastIndexOf(.); System.out.println(文件名是:+str); 15.从键盘输入两个字符串,输入两个字符串的连接. 使用concat()方法;/* * (#)conwords.java * * * author * version 1.00 2010/4/14 */import java.io.*;public class conwords /* * Creates a new instance of conwords. */ public conwords() /* * param args the command line arguments */ public static void main(String args) throws IOException / TODO code application logic here String str1=; String str2=; String str3=; BufferedReader in1=ne
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 白城社工面试题及答案
- 大学钳工考试题及答案
- 公司账务考试题及答案
- sql语句考试题及答案
- 集团副总面试题及答案
- 科研面试题模板及答案
- 爬楼梯java面试题及答案
- 基础院感培训
- 教育惩戒实施策略与方法
- 中式厨艺培训
- SB/T 10784-2012洗染服务合约技术规范
- GB/T 16940-2012滚动轴承套筒型直线球轴承外形尺寸和公差
- GB/T 15814.1-1995烟花爆竹药剂成分定性测定
- 煤矿安全规程露天部分参考题库(含答案)
- 紫铜材质证明
- 新产品评审管理办法
- (参考)菲达公司国内电除尘器业绩表
- 游泳池水质检测记录表
- 大学生职业生涯规划与就业指导教案第5讲:兴趣探索
- 门店电表记录表
- 七年级劳技 花卉种植 花卉用途 PPT学习教案
评论
0/150
提交评论