摘要:public Class ComputerCircleArea{public static void main(String args[]){double radius;double area;radius=163.16;area=3.14*radius*radius;System.out.printf("半径是%5.3f的圆的面积:\n%5.3f",radius,area);}} 阅读全文
Example3_8
2013-03-31 10:52 by 郭莹莹1114010807, 108 阅读, 0 推荐, 收藏, 编辑
摘要:import java.util.Scanner;public class Example3_8{public static void main(String args[]){int n,start,end,middle;int a[]={-2,1,4,5,8,12,17,23,45,56,90,100};start=0;end=a.length;middle=(start+end)/2;int count=0;Scanner reader=new Scanner(System.in);System.out.print("请输入一个整数:");n=reader.nextIn 阅读全文
Example3_5
2013-03-31 10:05 by 郭莹莹1114010807, 141 阅读, 0 推荐, 收藏, 编辑
摘要:public class Example3_5{public static void main(String args[]){double sum=0,item=1;int i=1;while(i<=1000){sum=sum+item;i++;item=item*(1.0/i);}sum=sum+1;System.out.println("e="+sum);sum=0;i=1;item=1;do{sum=sum+item;i++;item=item*(1.0/i);}while(i<=1000);sum=sum+1;System.out.println(&qu 阅读全文
Example3_3
2013-03-30 11:11 by 郭莹莹1114010807, 121 阅读, 0 推荐, 收藏, 编辑
摘要:import java.util.*;public class Example3_3{public static void main(String args[]){Scanner reader=new Scanner(System.in);double a=0,b=0,c=0;System.out.print("输入边a:");a=reader.nextDouble();System.out.print("输入边b:");b=reader.nextDouble();System.out.print("输入边c:");c=reader. 阅读全文
Example3_1
2013-03-30 10:30 by 郭莹莹1114010807, 114 阅读, 0 推荐, 收藏, 编辑
摘要:import java.util.*;public class Example3_1{public static void main(String args[]){Scanner reader=new Scanner(System.in);System.out.println("输入待移位的int型整数:");int x=reader.nextInt();System.out.println("输入移位量:");int n=reader.nextInt();System.out.println("左移位的结果:"+(x<< 阅读全文
2-4
2013-03-17 20:30 by 郭莹莹1114010807, 146 阅读, 0 推荐, 收藏, 编辑
摘要:import java.util.*;public class Example2_4 { public static void main(String arg[]){ Scanner reader=new Scanner(System.in); double sum=0; int m=0; while(reader.hasNextDouble()){ double x=reader.nextDouble(); m=m+1; sum=sum+x; } System.out.printf("%d个数的和为%f\n",m,sum); System.out.printf(" 阅读全文
2-3
2013-03-17 20:27 by 郭莹莹1114010807, 186 阅读, 0 推荐, 收藏, 编辑
摘要:public class Example2_3 { public static void main (String args[]){ char c='A'; float f=123.456789f; double d=123456.12345678; long x=5678; System.out.printf("%c%n10.3f%n%f,%12d%n%d",c,f,d,x,x=x+2); }} 阅读全文
第二章例题
2013-03-17 20:24 by 郭莹莹1114010807, 110 阅读, 0 推荐, 收藏, 编辑
摘要:public class Example2_1 { public static void main (String args[]){ char c='a'; System.out.println("zimu"+c+"in the unicode canlender consition:"+(int)c); System.out.println("zimubiao:"); for(int i=(int)c;i<c+25;i++){ System.out.print(""+(char)i); } 阅读全文
例题
2013-03-17 19:53 by 郭莹莹1114010807, 131 阅读, 0 推荐, 收藏, 编辑
摘要:long d=8000; float f; double g=0.1234567812345678; a=(byte)b; c=(int)d; f=(float)g; System.out.println("a="+a); System.out.println("c="+c); System.out.println("f="+f); System.out.println("g="+g); } } 阅读全文
例题代码2
2013-03-16 12:21 by 郭莹莹1114010807, 118 阅读, 0 推荐, 收藏, 编辑
摘要:public class Tom{int leg;String head;void cry(String s){System.out.println(s);}}class Example{public static void main(String args[]){Tom cat;cat=new Tom();cat.leg=4;cat.head="maotuo";System.out.println("tui:"+cat.leg+"tiao");System.out.println("tou :"+cat.head 阅读全文