北美微论坛

App下载
扫码下载 App
联系我们
1框架
查看: 618|回复: 8
打印 上一主题 下一主题

[CS/EE] C++ 题目求解救

[复制链接]

博士后

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2016-2-8 13:47:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 psm494 于 2016-2-8 13:59 编辑

Lab 2 (loop and selection)
Problem 1 (Displaying pyramid) Write a program that prompts the user to enter an integer from 1 to 9and display a pyramid, as shown in the following sample output:

Enter the number of lines: 5
                                    1
                                2  1  2
                           3  2  1 2  3
                       4  3  2 1  2  3  4
                   5  4  3 2  1  2 3  4  5

Problem 2 (Displayingcalendar) Write a program that prompts the user to enter the year and first dayof the year and displays on the console the calendar table for the year. Forexample, if the user entered the year 2005, and 6 for Saturday, January 1,2005, your program should display the calendar for each month in the year, as follows:

                January 2005
---------------------------------------------------
Sun      Mon     Tue      Wed    Thu      Fri        Sat
                                                                        1
2          3          4          5          6          7          8
9          10        11        12        13        14        15
16        17        18        19        20        21        22
23        24        25        26        27        28        29
30        31
…….

               December 2005
---------------------------------------------------
Sun      Mon     Tue      Wed    Thu      Fri        Sat
                                                1          2          3
4          5          6          7          8          9          10
11        12        13        14        15        16        17
18        19        20        21        22        23        24
25        26        27        28        29        30        31


(Hint: thenumber of days in February for different year may be different, which dependson whether it is a leap year or plain year. A year is leap year if either (1)or (2) holds: (1) it is divisible by 400. (2) it is divisible by 4 but notdivisible by 100.
收藏收藏 分享分享 赞赞赞!赞赞赞! 踩踩踩!踩踩踩! 新浪微博微博分享
回复

使用道具 举报

科学家

Rank: 13Rank: 13Rank: 13Rank: 13

沙发
发表于 2016-2-8 14:02:39 | 只看该作者

回帖奖励 +5

你把题目全贴到google就能搜到
回复

使用道具 举报

禁止发言

鸡腿爱好者

最佳新人常驻居民论坛元老申诉壮士

板凳
发表于 2016-2-8 14:14:12 来自手机 | 只看该作者

回帖奖励 +5

提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

博士后

Rank: 7Rank: 7Rank: 7

地板
 楼主| 发表于 2016-2-8 14:15:01 | 只看该作者
找不到啊。。。有也是java的
回复

使用道具 举报

高级院士

Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15

5#
发表于 2016-2-8 15:15:44 | 只看该作者

回帖奖励 +5

帮顶
花落成泥,碾作尘,只有香如故。
回复

使用道具 举报

博士后

Rank: 7Rank: 7Rank: 7

6#
发表于 2016-2-8 23:14:27 | 只看该作者

回帖奖励 +5

这跟cpp没关系,找个答案的代码,改成cpp就是了, 都是语法区别.

回复

使用道具 举报

院士

Rank: 14Rank: 14Rank: 14Rank: 14

最佳新人申诉壮士常驻居民

7#
发表于 2016-2-9 08:29:04 | 只看该作者

回帖奖励 +5

帮顶
回复

使用道具 举报

小学生

Rank: 1

8#
发表于 2016-2-9 10:21:25 | 只看该作者
你可以加我的微信sasa-5575
回复

使用道具 举报

博士后

Rank: 7Rank: 7Rank: 7

9#
 楼主| 发表于 2016-2-10 15:09:56 来自手机 | 只看该作者
已经码出来了   多谢大家
来自: iPhone客户端
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

返回顶部