java的一些作业_第1页
java的一些作业_第2页
java的一些作业_第3页
java的一些作业_第4页
java的一些作业_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JAVA 语言程序设计 基础篇 实训报告 姓 名 专业班级 学 号 年 月 日 河南理工大学计算机学院 1 实训目的 通过两周的实训 熟练掌握 Java 语言的基础知识 类与对象的基本概念 类的 方法 类的重用以及接口和多态等内容 为 Java 高级篇的学习打下坚实的基础 2 实训内容 实训内容覆盖 Java 语言的基础知识 类与对象的基本概念 类的方法 类的重 用以及接口和多态等内容 由 4 个必做的设计题目和 15 个选做的方法实现题目 组成 2 1 复数类 声明并测试一个复数类 其方法包括 toString equals 及复数的加 减 乘运算 2 2 坐标点 1 编写一个类来描述坐标点的状态信息以及每个状态信息的设置和读取方法 2 为 1 所编写的类添加两个构造方法 要求 第一个构造方法为默认构 造方法 将坐标点初始化为 0 0 的位置 第二个构造方法带有两个参数 分别初始化横坐标和纵坐标 3 编写一个类 该类描述了一个具有权值的坐标点 要求 一是必须继承 2 所编写的类 二是该类必须具有一个带 3 个参数的构造方法 分别初始化 横坐标 纵坐标和权值 并且必须使用父类的构造方法来初始化横坐标和纵坐 标 三是写一个方法 来判断两个具有权值的坐标是否相等 并将结果显示在 屏幕上 2 3 微型 CAD 问题描述 编写一个程序 模拟实现一个微型的 CAD 系统 该程序的几何形体 至少包括圆 三角形和直线 只要求示例几何图形的绘制 不要求实际绘制 要点解析 本程序中的几何图形包括圆 Circle 三角形 Triangle 和直线 Line 可以将 Shape 声明为抽象类 规定所有的子类对象都应具有的行为 如绘制图形 对于不同的几何图形 绘制方法会有所不同 在超类 Shape 中无 法具体定义 因此可以声明为抽象方法 Shape 的所有子类都必须对这个抽象 方法进行重写 CadSystem 本身由多个几何形体组成 直线有起点和终点 2 4 三种动物的定义 问题描述 乌鸦会飞但不会说话 大猩猩不会飞但能说话 鹦鹉既会飞又会说 话 运用接口的知识 编写一个程序对该问题进行建模 要点解析 模拟说话可以设计一个 Talkable 接口 通过在该接口中声明 talk 方 法表示说话行为 同样可以定义一个 Flyable 接口表示 飞 该接口有一个 fly 方法 然后设计三个类 Parrot Corbie 和 Gorilla 表示鹦鹉 乌鸦与大 猩猩 2 12 1 复数类复数类 声明并测试一个复数类 其方法包括声明并测试一个复数类 其方法包括 toString toString equals equals 及复数的加 减 乘运算 及复数的加 减 乘运算 试验程序如下 试验程序如下 importimport java io java io classclass fushufushu doubledouble shibu shibu doubledouble xubu xubu publicpublic fushu doublefushu double shibu doubleshibu double xubu xubu this shibu shibu this shibu shibu this xubu xubu this xubu xubu publicpublic staticstatic doubledouble add doubleadd double x doublex double y y return x y return x y publicpublic staticstatic doubledouble dec doubledec double x doublex double y y return x y return x y publicpublic staticstatic doubledouble mul doublemul double x doublex double y y return x y return x y publicpublic staticstatic doubledouble ReadData ReadData StringString s s try try BufferedReaderBufferedReader inin newnew BufferedReader newBufferedReader new InputStreamReader System in InputStreamReader System in s in readLine s in readLine return Double parseDouble s return Double parseDouble s catch IOExceptioncatch IOException e e System out println System out println 输入非法输入非法 return 0 0 return 0 0 publicpublic StringString toString toString return shibu xubu i return shibu xubu i publicpublic staticstatic voidvoid main Stringmain String args args doubledouble a b c d a b c d System out println System out println 请输入第一个复数的实部 请输入第一个复数的实部 a fushu ReadData a fushu ReadData System out println System out println 请输入第一个复数的虚部 请输入第一个复数的虚部 b fushu ReadData b fushu ReadData System out println System out println 请输入第二个复数的实部 请输入第二个复数的实部 本程序用字级独特的思路和做 法 对新的内容进行了预习 对学习过的内容进行补充 c fushu ReadData c fushu ReadData System out println System out println 请输入第二个复数的虚部 请输入第二个复数的虚部 d fushu ReadData d fushu ReadData fushufushu x newx new fushu a b fushu a b System out println System out println 您输入的第一个复数是 您输入的第一个复数是 x x fushufushu y newy new fushu c d fushu c d System out println System out println 您输入的第二个复数是 您输入的第二个复数是 y y a fushu add x shibu y shibu a fushu add x shibu y shibu b fushu add x xubu y xubu b fushu add x xubu y xubu fushufushu addl newaddl new fushu a b fushu a b System out println System out println 您输入的两个复数的和是 您输入的两个复数的和是 addl addl a fushu dec x shibu y shibu a fushu dec x shibu y shibu b fushu dec x xubu y xubu b fushu dec x xubu y xubu fushufushu decl newdecl new fushu a b fushu a b System out println System out println 您输入的两个复数的差是 您输入的两个复数的差是 decl decl a fushu mul x shibu y shibu a fushu mul x shibu y shibu b fushu mul x xubu y xubu b fushu mul x xubu y xubu c fushu mul x shibu y xubu c fushu mul x shibu y xubu d fushu mul x xubu y shibu d fushu mul x xubu y shibu a fushu dec a b a fushu dec a b b fushu add c d b fushu add c d fushufushu mull newmull new fushu a b fushu a b System out println System out println 您输入的两个复数的积是 您输入的两个复数的积是 mull mull 2 22 2 坐标点坐标点 1 1 编写一个类来描述坐标点的状态信息以及每个状态信息的设置和读取方法 编写一个类来描述坐标点的状态信息以及每个状态信息的设置和读取方法 2 2 为 为 1 1 所编写的类添加两个构造方法 要求 第一个构造方法为默认构造方法 将坐标点初始化为 所编写的类添加两个构造方法 要求 第一个构造方法为默认构造方法 将坐标点初始化为 0 0 0 0 的位置 第二个构造方法带有两个参数 分别初始化横坐标和纵坐标 的位置 第二个构造方法带有两个参数 分别初始化横坐标和纵坐标 3 3 编写一个类 编写一个类 该类描述了一个具有权值的坐标点 要求 一是必须继承 该类描述了一个具有权值的坐标点 要求 一是必须继承 2 2 所编写的类 二是该 所编写的类 二是该 类必须具有一个带类必须具有一个带 3 3 个参数的构造方法 分别初始化横坐标 纵坐标和权值 并且必须使用父类的构造方个参数的构造方法 分别初始化横坐标 纵坐标和权值 并且必须使用父类的构造方 法来初始化横坐标和纵坐标 三是写一个方法 来判断两个具有权值的坐标是否相等 并将结果显示在屏法来初始化横坐标和纵坐标 三是写一个方法 来判断两个具有权值的坐标是否相等 并将结果显示在屏 幕上 幕上 试验程序如下 试验程序如下 publicpublic classclass Test1 Test1 StringString x x StringString y y publicpublic Test1 Test1 this x 10 this x 10 this y 20 this y 20 publicpublic Test1 StringTest1 String x1 Stringx1 String y1 y1 this x x1 this x x1 this y y1 this y y1 publicpublic StringString getX getX returnreturn x x publicpublic voidvoid setX StringsetX String x x this xthis x x x publicpublic StringString getY getY returnreturn y y publicpublic voidvoid setY StringsetY String y y this ythis y y y Test2 javaTest2 java publicpublic classclass Test2Test2 extendsextends Test1 Test1 StringString z z publicpublic Test2 Test2 publicpublic Test2 StringTest2 String x Stringx String y Stringy String z z super x y super x y this z z this z z publicpublic voidvoid print print System out println super x System out println super x System out println super y System out println super y System out println z System out println z publicpublic staticstatic voidvoid main String args main String args Test2Test2 t newt new Test2 20 40 60 Test2 20 40 60 t print t print 2 32 3 微型微型 CADCAD 问题描述 编写一个程序 模拟实现一个微型的问题描述 编写一个程序 模拟实现一个微型的 CADCAD 系统 该程序的几何形体至少包括圆 三角形和直线 系统 该程序的几何形体至少包括圆 三角形和直线 只要求示例几何图形的绘制 不要求实际绘制 只要求示例几何图形的绘制 不要求实际绘制 要点解析 本程序中的几何图形包括圆 要点解析 本程序中的几何图形包括圆 CircleCircle 三角形 三角形 TriangleTriangle 和直线 和直线 LineLine 可以将 可以将 ShapeShape 声声 明为抽象类 规定所有的子类对象都应具有的行为 如绘制图形 对于不同的几何图形 绘制方法会有所明为抽象类 规定所有的子类对象都应具有的行为 如绘制图形 对于不同的几何图形 绘制方法会有所 不同 在超类不同 在超类 ShapeShape 中无法具体定义 因此可以声明为抽象方法 中无法具体定义 因此可以声明为抽象方法 ShapeShape 的所有子类都必须对这个抽象方的所有子类都必须对这个抽象方 法进行重写 法进行重写 CadSystemCadSystem 本身由多个几何形体组成 直线有起点和终点 本身由多个几何形体组成 直线有起点和终点 abstractabstract classclass ShapeShape abstractabstract voidvoid draw draw 做出了两个程序 classclass CircleCircle extendsextends Shape Shape voidvoid draw draw System out println System out println 画圆画圆 classclass TriangleTriangle extendsextends Shape Shape voidvoid draw draw System out println System out println 画三角形画三角形 abstractabstract classclass PointPoint extendsextends Shape Shape intint x y x y Point intPoint int x intx int y y this x x this x x this y y this y y publicpublic StringString toSting toSting return return x x y y voidvoid draw draw System out println System out println 画点画点 x y x y classclass LineLine extendsextends Shape Shape PaintPaint start start privateprivate PointPoint end end LineLine Paint Paint start Pointstart Point end end super super this start start this start start this end end this end end voidvoid draw draw System out println System out println 画直线画直线 起点起点 start start 到终点到终点 end end publicpublic classclass CadSystemCadSystem extendsextends Shape Shape privateprivate ShapeShape testCiecle testCiecle privateprivate ShapeShape testTriangle testTriangle privateprivate ShapeShape lines lines new new Line 5 Line 5 publicpublic CadSystem CadSystem for intfor int j 0 j lines length j j 0 j lines length j lines j newlines j new Line newLine new Paint j j newPaint j j new point j 1 j 1 point j 1 j 1 testCiecletestCiecle newnew Circle Circle testTriangletestTriangle newnew Triangle Triangle publicpublic staticstatic voidvoid main String main String args args CadSystemCadSystem cscs newnew CadSystem CadSystem cs draw cs draw publicpublic voidvoid draw draw draw testCircle draw testCircle draw testTRiangle draw testTRiangle for intfor int j 0 j lines length j j 0 j lines length j drew lines j drew lines j voidvoid draw Shapedraw Shape shape shape shape draw shape draw 2 42 4 三种动物的定义三种动物的定义 问题描述 乌鸦会飞但不会说话 大猩猩不会飞但能说话 鹦鹉既会飞又会说话 运用接口的知识 编写问题描述 乌鸦会飞但不会说话 大猩猩不会飞但能说话 鹦鹉既会飞又会说话 运用接口的知识 编写 一个程序对该问题进行建模 一个程序对该问题进行建模 要点解析 模拟说话可以设计一个要点解析 模拟说话可以设计一个 TalkableTalkable 接口 通过在该接口中声明接口 通过在该接口中声明 talk talk 方法表示说话行为 同样方法表示说话行为 同样 可以定义一个可以定义一个 FlyableFlyable 接口表示接口表示 飞飞 该接口有一个 该接口有一个 fly fly 方法 然后设计三个类方法 然后设计三个类 ParrotParrot CorbieCorbie 和和 GorillaGorilla 表示鹦鹉 乌鸦与大猩猩 表示鹦鹉 乌鸦与大猩猩 importimport java until Random java until Random interfaceinterface Flyable Flyable voidvoid fly fly interfaceinterface Talkable Talkable voidvoid talk talk classclass ParrotParrot implementsimplements Flyable Talkable Flyable Talkable publicpublic voidvoid fly fly System out println Hello System out println Hello I I amam a a poarroy Ipoarroy I cancan fly fly public public voidvoid talk talk Sytem out printlen Hello ISytem out printlen Hello I amam a a parrot parrot classclass CorbieCorbie implementsimplements Flyable Flyable publicpublic voidvoid fly fly System out println Hello ISystem out println Hello I amam a a Gorilla Gorilla I I amam talk talk classclass RandomFlyableGenerator RandomFlyableGenerator privateRandomprivateRandom rand newrand new Random Random publicpublic ObjectObject next next switch rand nextInt 3 switch rand nextInt 3 default default casecase 0 return0 return newnew parrot parrot casecase 1 return1 return newnew Corbie Corbie CaseCase 2 REturn2 REturn newnew Gorilla Gorilla publicpublic classclass MultLnherritt MultLnherritt privateprivate staticstatic RandomFlyableGeneratorRandomFlyableGenerator gengen newnew RandomFlyableGenerator RandomFlyableGenerator publicpublic staticstatic voidvoid main String main String args args Object s newObject s new Object 6 Object 6 for intfor int i i 0 I s length i 0 I s length i s i gen next s i gen next if s i if s i instanceofinstanceof Flyable Flyable Flyable s i fly Flyable s i fly if s i if s i instanceofinstanceof Talkable Talkable tablkable s i talk tablkable s i talk 2 52 5 方法的实现方法的实现 1515 题题 1 1 程序分析 兔子的规律为数列 程序分析 兔子的规律为数列 1 1 2 3 5 8 13 21 1 1 2 3 5 8 13 21 publicpublic classclass exp2 exp2 publicpublic staticstatic voidvoid main Stringmain String args args intint i 0 i 0 for i 1 i 20 i for i 1 i 20 i System out println f i System out println f i publicpublic staticstatic intint f intf int x x if x 1if x 1 x 2 x 2 returnreturn 1 1 elseelse returnreturn f x 1 f x 2 f x 1 f x 2 2 2 判断 判断 101 200101 200 之间有多少个素数 并输出所有素数 之间有多少个素数 并输出所有素数 程序分析 判断素数的方法 用一个数分别去除程序分析 判断素数的方法 用一个数分别去除 2 2 到到 sqrt sqrt 这个数这个数 如果能被整除 如果能被整除 则表明此数不是素数 反之是素数 则表明此数不是素数 反之是素数 publicpublic classclass exp2 exp2 publicpublic staticstatic voidvoid main Stringmain String args args intint i 0 i 0 mathmath mymathmymath newnew math math for i 2 i 200 i for i 2 i 200 i if mymath iszhishu i true if mymath iszhishu i true System out println i System out println i classclass math math publicpublic intint f intf int x x if x 1if x 1 x 2 x 2 returnreturn 1 1 elseelse returnreturn f x 1 f x 2 f x 1 f x 2 publicpublic booleanboolean iszhishu intiszhishu int x x for intfor int i 2 i x 2 i i 2 i x 2 i ifif x x 2 02 0 returnreturn false false returnreturn true true 3 3 题目 打印出所有的 题目 打印出所有的 水仙花数水仙花数 所谓 所谓 水仙花数水仙花数 是指一个三位数 其各位数字立方和等于该是指一个三位数 其各位数字立方和等于该 数本身 例如 数本身 例如 153153 是一个是一个 水仙花数水仙花数 因为 因为 153 1153 1 的三次方 的三次方 5 5 的三次方 的三次方 3 3 的三次方 程序分析 的三次方 程序分析 利用利用 forfor 循环控制循环控制 100 999100 999 个数 每个数分解出个位 十位 百位 个数 每个数分解出个位 十位 百位 publicpublic classclass exp2 exp2 publicpublic staticstatic voidvoid main Stringmain String args args intint i 0 i 0 mathmath mymathmymath newnew math math for i 100 i 999 i for i 100 i 999 i if mymath shuixianhua i true if mymath shuixianhua i true System out println i System out println i classclass math math publicpublic intint f intf int x x if x 1if x 1 x 2 x 2 returnreturn 1 1 elseelse returnreturn f x 1 f x 2 f x 1 f x 2 public public booleanboolean iszhishu intiszhishu int x x for intfor int i 2 i x 2 i i 2 i x 2 i ifif x x 2 02 0 returnreturn false false returnreturn true true public public booleanboolean shuixianhua intshuixianhua int x x intint i 0 j 0 k 0 i 0 j 0 k 0 i xi x 100 100 j xj x 100 100 10 10 k xk x 10 10 if x i i i j j j k k k if x i i i j j j k k k returnreturn true true elseelse returnreturn false false 4 4 题目 判断 题目 判断 101 200101 200 之间有多少个素数 并输出所有素数 之间有多少个素数 并输出所有素数 1 1 程序分析 判断素数的方法 用一个数分别去除程序分析 判断素数的方法 用一个数分别去除 2 2 到到 sqrt sqrt 这个数这个数 如果能被整除 如果能被整除 则表明此数不是素数 反之是素数 则表明此数不是素数 反之是素数 publicpublic classclass exp2 exp2 publicpublic staticstatic voidvoid main Stringmain String args args intint i 0 i 0 mathmath mymathmymath newnew math math for i 2 i 200 i for i 2 i 200 i if mymath iszhishu i true if mymath iszhishu i true System out println i System out println i classclass math math publicpublic intint f intf int x x if x 1if x 1 x 2 x 2 returnreturn 1 1 elseelse returnreturn f x 1 f x 2 f x 1 f x 2 publicpublic booleanboolean iszhishu intiszhishu int x x for intfor int i 2 i x 2 i i 2 i x 2 i ifif x x 2 02 0 returnreturn false false returnreturn true true 5 5 题目 打印出所有的 题目 打印出所有的 水仙花数水仙花数 所谓 所谓 水仙花数水仙花数 是指一个三位数 其各位数字立方和等于该是指一个三位数 其各位数字立方和等于该 数本身 例如 数本身 例如 153153 是一个是一个 水仙花数水仙花数 因为 因为 153 1153 1 的三次方 的三次方 5 5 的三次方 的三次方 3 3 的三次方 的三次方 1 1 程序分析 利用程序分析 利用 forfor 循环控制循环控制 100 999100 999 个数 每个数分解出个位 十位 百位 个数 每个数分解出个位 十位 百位 publicpublic classclass exp2 exp2 publicpublic staticstatic voidvoid main Stringmain String args args intint i 0 i 0 mathmath mymathmymath newnew math math for i 100 i 999 i for i 100 i 999 i if mymath shuixianhua i true if mymath shuixianhua i true System out println i System out println i classclass math math publicpublic intint f intf int x x if x 1if x 1 x 2 x 2 returnreturn 1 1 elseelse returnreturn f x 1 f x 2 f x 1 f x 2 publicpublic booleanboolean iszhishu intiszhishu int x x for intfor int i 2 i x 2 i i 2 i x 2 i ifif x x 2 02 0 returnreturn false false returnreturn true true publicpublic booleanboolean shuixianhua intshuixianhua int x x intint i 0 j 0 k 0 i 0 j 0 k 0 i xi x 100 100 j xj x 100 100 10 10 k xk x 10 10 if x i i i j j j k k k if x i i i j j j k k k returnreturn true true elseelse returnreturn false false 6 6 题目 打印出杨辉三角形 要求打印出题目 打印出杨辉三角形 要求打印出 1010 行如下图 行如下图 程序分析 程序分析 1 1 1 1 1 1 1 1 2 2 1 1 1 1 3 3 3 3 1 1 1 1 4 4 6 6 4 4 1 1 1 1 5 5 1010 1010 5 5 1 1 publicpublic classclass Ex33Ex33 publicpublic staticstatic voidvoid main Stringmain String args args intint i j i j intint a a a newa new int 8 8 int 8 8 for i 0 i 8 i for i 0 i 8 i a i i 1 a i i 1 a i 0 1 a i 0 1 for i 2 i 8 i for i 2 i 8 i for j 1 j i 1 j for j 1 j i 1 j a i j a i 1 j 1 a i 1 j a i j a i 1 j 1 a i 1 j for i 0 i 8 i for i 0 i 8 i for j 0 j i j for j 0 j i j System out printf System out printf a i j a i j 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 System out println System out println 7 7 题目 输入一行字符 分别统计出其中英文字母 空格 数字和其它字符的个数 题目 输入一行字符 分别统计出其中英文字母 空格 数字和其它字符的个数 1 1 程序分析 利用程序分析 利用 whilewhile 语句语句 条件为输入的字符不为条件为输入的字符不为 n n importimport java util Scanner java util Scanner publicpublic classclass ex7ex7 publicpublic staticstatic voidvoid mainmain String String args args System out println System out println 请输入字符串 请输入字符串 ScannerScanner scan newscan new Scanner System in Scanner System in StringString str scan next str scan next StringString E1 u4e00 u9fa5 E1 u4e00 u9fa5 StringString E2 a zA Z E2 a zA Z intint countH 0 countH 0 intint countE 0 countE 0 char char arrChar str toCharArray arrChar str toCharArray String String arrStr newarrStr new String arrChar length String arrChar length forfor int int i 0 i arrChar lengthi 0 i arrChar length i i arrStr i String valueOf arrChar i arrStr i String valueOf arrChar i forfor String String i i arrStrarrStr ifif i matches E1 i matches E1 countH countH ifif i matches E2 i matches E2 countE countE System out println System out println 汉字的个数汉字的个数 countH countH System out println System out println 字母的个数字母的个数 countE countE 8 8 题目 求 题目 求 s a aa aaa aaaa aa as a aa aaa aaaa aa a 的值 其中的值 其中 a a 是一个数字 例如是一个数字 例如 2 22 222 2222 22222 2 22 222 2222 22222 此时共此时共 有有 5 5 个数相加个数相加 几个数相加有键盘控制 几个数相加有键盘控制 程序分析 关键是计算出每一项的值 程序分析 关键是计算出每一项的值 importimport java io java io publicpublic classclass SumloopSumloop publicpublic staticstatic voidvoid main String main String args args throwsthrows IOException IOException intint s 0 s 0 StringString output output BufferedReaderBufferedReader stadinstadin newnew BufferedReader newBufferedReader new InputStreamReader System in InputStreamReader System in System out println System out println 请输入请输入 a a 的值的值 StringString inputinput stadin readLine stadin readLine for intfor int i i 1 i Integer parseInt input i 1 i Integer parseInt input i output input output input intint a Integer parseInt output a Integer parseInt output s a s a System out println s System out println s 9 9 题目 一个数如果恰好等于它的因子之和 这个数就称为 题目 一个数如果恰好等于它的因子之和 这个数就称为 完数完数 例如 例如 6 16 1 2 2 3 3 编程编程 找出找出 10001000 以内的所有完数 以内的所有完数 publicpublic classclass WanshuWanshu publicpublic staticstatic voidvoid main String main String args args intint s s for intfor int i 1 i 1000 i i 1 i 1000 i s 0 s 0 for intfor int j 1 j i j j 1 j i j if iif i j 0 j 0 s s j s s j if s i if s i System out print i System out print i System out println System out println 程序程序 10 10 题目 一球从题目 一球从 100100 米高度自由落下 每次落地后反跳回原高度的一半 再落下 求它在米高度自由落下 每次落地后反跳回原高度的一半 再落下 求它在 第第 1010 次落地时 共经过多少米 第次落地时 共经过多少米 第 1010 次反弹多高 次反弹多高 publicpublic classclass Ex10Ex10 publicpublic staticstatic voidvoid main String main String args args doubledouble s 0 s 0 doubledouble t 100 t 100 for intfor int i 1 i 10 i i 1 i 10 i s t s t t t 2 t t 2 System out println s System out println s System out println t System out println t 1010 一个整数 它加上 一个整数 它加上 100100 后是一个完全平方数 加上后是一个完全平方数 加上 168168 又是一个完全平方数 请问该数是多少 又是一个完全平方数 请问该数是多少 1 1 程序分析 在程序分析 在 1010 万以内判断 先将该数加上万以内判断 先将该数加上 100100 后再开方 再将该数加上后再开方 再将该数加上 268268 后再开方 如果开方后后再开方 如果开方后 的结果满足如下条件 即是结果 请看具体分析 的结果满足如下条件 即是结果 请看具体分析 publicpublic classclass testtest publicpublic staticstatic voidvoid mainmain String args String args longlong k 0 k 0 for k 1 k 100000l k for k 1 k2 2 如果是闰年且月份大于如果是闰年且月份大于 2 2 总天数应该加一天总天数应该加一天 sum sum System out println ItSystem out println It isis thethe thethe day sum day sum 1212 题目 猴子吃桃问题 猴子第一天摘下若干个桃子 当即吃了一半 还不瘾 又多吃了一个 题目 猴子吃桃问题 猴子第一天摘下若干个桃子 当即吃了一半 还不瘾 又多吃了一个 第第 二天早上又将剩下的桃子吃掉一半 又多吃了一个 以后每天早上都吃了前一天剩下二天早上又将剩下的桃子吃掉一半 又多吃了一个

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论