




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
4.11题public class s11 /* * param args */public static void main(String args) / TODO Auto-generated method stub int count=0;for(int i=100;i=200;i+) if(i%5=0|i%6=0)&(i%30!=0) count+; System.out.print(i+ ); if(count%10=0) System.out.println(); 结果:100 102 105 108 110 114 115 125 126 130 132 135 138 140 144 145 155 156 160 162 165 168 170 174 175 185 186 190 192 195 198 2004.18题apublic class S411 /* * param args */public static void main(String args) / TODO Auto-generated method stub for(int i=0;i6;i+) for(int j=0;j=i;) System.out.print(+j); System.out.println(); 结果:11212312341234512345618题cpublic class c18 /* * param args */public static void main(String args) / TODO Auto-generated method stubint i,j;for(i=0;ii;j-)System.out.print( );for(j=i+1;j0;j-)System.out.print(j); System.out.println(); 结果:1 21 321 4321 54321654321第五章编程练习作业5.2import javax.swing.*;public class s52 /* * param args */public static void main(String args) / TODO Auto-generated method stublong m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);System.out.print(sumDigits(m);public static long sumDigits(long n)long sum=0;long i=0;while(n!=0)i=n%10;n=n/10;sum=sum+i;return sum;5.4import javax.swing.JOptionPane;public class s54 /* * param args */public static void main(String args) / TODO Auto-generated method stubint m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);reverse(m);public static void reverse(int n)long i=0;while(n!=0)i=n%10;n=n/10;System.out.print(i);5.4import javax.swing.JOptionPane;public class s544 /* * param args */public static void main(String args) / TODO Auto-generated method stublong m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);System.out.print(sumDigits(m);public static long sumDigits(long n)long sum=0;long i=0;while(n!=0)i=n%10;n=n/10;sum=sum*10+i;return sum;6.5import javax.swing.JOptionPane;public class 6.5public static void main(String args)int num = new int10;boolean zero = false;int j = 0;for(int i = 0;i 10 ;i+)int number = Integer.parseInt(JOptionPane.showInputDialog(Enter a number:);if(number = 0)zero = true;if(number != 0)for(j = 0;j = i)numi = number;if(zero)System.out.println(0);for(int i = 0;i num.length;i+)if(numi != 0)System.out.println(numi);6.7public class Exercise6_7 public static void main(String args) / TODO Auto-generated method stubint counts = new int10;int num = 0;for(int i = 0;i 100;i+)num = (int)(Math.random()*10);countsnum+;System.out.println(统计结果为:);System.out.print(随机数: );for(int i = 0;i counts.length ; i+)System.out.print( + i);System.out.print(n出现次数:);for(int i = 0;i counts.length ; i+)if(countsi 10)System.out.print( + countsi);else System.out.print( + countsi);7.1public class Rectangle double width=1;double height=1;String color=white;public Rectangle()public Rectangle(double width,double height,String color)this.width=width;this.height=height;this.color=color;public void setwidth(double width)this.width=width;public void setcolor(String color)this.color=color;public double getwidth()return width;public double getheight()return height;public double getArea()return width*height;public double getAPerimeter()return 2*(width+height); class Testpublic static void main(String args)Rectangle r1=new Rectangle(4,40,red);Rectangle r2=new Rectangle(3.5,35.9,red);r1.getArea();r1.getAPerimeter();r2.getArea();r2.getAPerimeter();Sy
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文化融合面试题目及答案
- 泸州高一学年末数学试卷
- 辽宁省三校生数学试卷
- 麻城市期末调研数学试卷
- 项目财务管理与监控方案
- 模拟会考数学试卷
- 六年级常熟期中数学试卷
- 平舆七年级期中数学试卷
- 汨罗市期末考试数学试卷
- 中医药综合楼项目建设工程方案
- 第二十章女性生殖内分泌疾病71课件
- 动能与均线策略(TB版)
- 检修工安全培训
- 2024奇安信网神安全感知与管理平台技术白皮书
- 《外墙外保温工程技术标准》(JGJ 144-2019)
- 年产30万平方米节能型新材料门窗项目环评报告表
- 做账实操-工业企业的账务处理
- JJF(黔) 86-2024 液体流量计在线校准规范
- 中建梁场临时用电施工组织设计
- 体育与健康课件
- 药品集采政策培训
评论
0/150
提交评论