




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025江西九江市武宁县医疗卫生单位招聘劳务派遣人员3人模拟试卷及答案详解(有一套)
- 2025年及未来5年中国地板革市场调查研究及行业投资潜力预测报告
- 2025年福建省莆田市东峤镇卫生院招聘2人考前自测高频考点模拟试题及参考答案详解一套
- 鱼苗早期发育调控-洞察与解读
- 2025湖南湘西自治州事业单位(医卫类)引进高层次急需紧缺人才考试模拟试卷及完整答案详解一套
- 2025届春季中建八局总承包公司校园招聘正式启动考前自测高频考点模拟试题及答案详解(历年真题)
- 班组安全月培训记录课件
- 2025河北承德市滦平县卫生健康局和滦平县医疗保障局所属事业单位选调医疗专业技术人员15人模拟试卷及答案详解(易错题)
- 2025贵州安顺市推进东西部协作工作领导小组办公室招聘合同制工作人员考前自测高频考点模拟试题及答案详解(有一套)
- 2025贵州云岩区某行政单位派遣制员工考前自测高频考点模拟试题附答案详解(典型题)
- TBT 3329-2013 电气化铁路接触网隧道内预埋槽道
- 2024版公司100%股权转让协议
- 消化内科护士进修汇报
- 2024年4月自考00840第二外语(日语)试题
- 便利店设计方案
- 对意外伤害儿童的紧急救治方法
- 为成果而管理
- 乳腺癌骨转移护理查房课件
- 新视野大学英语1读写教程-Unit1-Fresh-Start-课件
- 客户信息登记表
- 不合格品处置记录表(标准版)
评论
0/150
提交评论