• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
wangchunmei
博客园 首页 新随笔 联系 订阅 订阅 管理

2013年3月15日

Example3_2(异或运算)
摘要: public class Example3_2{public static void main(String arg[]){char a[]={'金','木','水','火','土'};char secret='z';for(int i=0;i<a.length;i++){a[i]=(char)(a[i]^secret);}System.out.printf("密文: \n");for(int i=0;i<a.length;i++){System.out.printf 阅读全文
posted @ 2013-03-15 21:16 wangchunmei 阅读(271) 评论(0) 推荐(0)
 
Example3_1(移位运算)
摘要: import java.util.*;public class Example3_1{public static void main(String arg[]){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<<n 阅读全文
posted @ 2013-03-15 20:40 wangchunmei 阅读(197) 评论(0) 推荐(0)
 
Example2_5(数组的引用)
摘要: public class Example2_5{public static void main(String arg[]){int [] a={1,2,3};int [] b={10,11};System.out.println("数组a的引用:"+a);System.out.println("数组b的引用:"+b);System.out.printf("b[0]=%-3db[1]=%-3d\n",b[0],b[1]);b=a;System.out.println("数组a的引用:"+a);System.out.p 阅读全文
posted @ 2013-03-15 20:17 wangchunmei 阅读(160) 评论(0) 推荐(0)
 
Example2_4(数据的输入Scanner)
摘要: 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("%d个数的平均值是%f 阅读全文
posted @ 2013-03-15 19:39 wangchunmei 阅读(136) 评论(0) 推荐(0)
 
Example2_3(数据输出System.out.printf)
摘要: public class Example2_3{public static void main(String arg[]){char c='A';float f=123.456789f;double d=123456.12345678;long x=5678;System.out.printf("%c%n%10.3f%n%f,%12d%n%d",c,f,d,x,x=x+2);}} 阅读全文
posted @ 2013-03-15 18:53 wangchunmei 阅读(184) 评论(0) 推荐(0)
 
Example2_2(基本类型转换)
摘要: public class Example2_2{public static void main(String arg[]){byte a=120;short b=130;int c=2200;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.prin 阅读全文
posted @ 2013-03-15 18:32 wangchunmei 阅读(257) 评论(0) 推荐(0)
 
Exaple2_1(显示转换)
摘要: public class Example2_1{public static void main(String arg[]){char c='a';System.out.println(""+c+"unicode:"+(int)c);System.out.println(":");for(int i=(int)c;i<c+25;i++){System.out.println(""+(char)i);}}} 阅读全文
posted @ 2013-03-15 18:07 wangchunmei 阅读(162) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3