资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1、从键盘输入一个正整数,按数字的相反顺序输出。package com.my.ccit;import java.util.Scanner;public class a1 public static void main(String args) Scanner s=new Scanner(System.in);int m= s.nextInt();int sum=0;int n;while(m!=0)n=m%10;m=m/10;sum=sum*10+n;System.out.println(sum);2、写一条for语句,计数条件为n从100200,步长为2;然后再用while语句实现同样的循环。package com.my.ccit;public class a2 public static void main(String args) int n;for(n=100;n=90&m=80)System.out.println(良);else if(m=70)System.out.println(中);else if(m=60)System.out.println(及格);else System.out.println(差);4、使用for循环语句求出1100之间的质数。package com.my.ccit;public class a4 /* * param args */public static void main(String args) / TODO Auto-generated method stub4、使用for循环语句求出1100之间的质数。int n;int j; boolean flag=false;for( n=1;n=100;n+) for(j=2;jmax)max=b;if(cmax)max=c;System.out.println(最大数为: +max);从键盘上输入3个数,把他们从大到小排列起来;package com.my.ccit;import java.util.Scanner;public class a6_3 public static void main(String args) Scanner s=new Scanner(System.in);System.out.println(输入3个数: );int a= s.nextInt();int b= s.nextInt();int c= s.nextInt(); int w; if(ab) w=a; a=b; b=w; if(ac) w=a; a=c; c=w; if(bc) w=b; b=c; c=w; System.out.println(从大到小顺序是:+a+ +b+ +c); 7、编写一个程序,对输入的4个整数,求出其中最大值和最小值。package com.my.ccit;import java.util.Scanner;public class a7public static void main(String args) Scanner s=new Scanner(System.in);System.out.println(输入4个数: );int a= s.nextInt();
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号