Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 2455|回复: 13
打印 上一主题 下一主题

C++ programming 大家帮我

[复制链接]

92

主题

8

好友

4470

积分

一流名嘴

来者何人

Rank: 12Rank: 12Rank: 12

跳转到指定楼层
1#
发表于 2009-10-8 10:06 PM |只看该作者 |倒序浏览
Write a program using for loops to produce a hollow box using the asterisk (*) symbol. The program should prompt the user for the height of the hollow box and check to see that the user entered a number greater than or equal to 3 and less than or equal to 40. If the user enters an invalid number, the program will print an error message and exit. If the user enters a valid number the program will print a hollow box of height and width n, where n is the number the user entered at the console.


我很乱

我是新手。。。。

谢谢


如果有人愿意帮我

麻烦

pm我

我给你我的msn。。。

  1. #include <stdio.h>
  2. int main()
  3. {
  4.         int i,j,k;
  5.         printf("Enter a value:\n");
  6.         scanf("%d", &i,j,k);
  7.         {
  8.         for(i=0; i<=3; i++)
  9.         for(j=0; j>=40; j--)
  10.         printf(" ");
  11.         {
  12.         for(k=1; k<=i; k=k+1)
  13.         printf("*");
  14.         printf("\n");
  15. }
  16. }
  17. }
复制代码

[ 本帖最后由 ぁあぃ← 于 2009-10-8 10:13 PM 编辑 ]




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 2009-10-8 10:37 PM |只看该作者
原帖由 ぁあぃ← 于 2009-10-8 10:06 PM 发表
Write a program using for loops to produce a hollow box using the asterisk (*) symbol. The program should prompt the user for the height of the hollow box and check to see that the user entered a ...



看來基礎該好好提升, 還有如果不清楚該怎麼做的話, 先畫出 flow chart 才開始編寫


回复

使用道具 举报

92

主题

8

好友

4470

积分

一流名嘴

来者何人

Rank: 12Rank: 12Rank: 12

3#
发表于 2009-10-8 10:46 PM |只看该作者

回复 #2 Super-Tomato 的帖子

flow chart又是什么?==

我这个是short sememster==

3个月

根本什么都没学到


回复

使用道具 举报

3

主题

0

好友

2953

积分

白金长老

Rank: 10

4#
发表于 2009-10-8 11:18 PM |只看该作者
刚写好的,拿去参考吧 (不知道对不对)


代码:
  1. /******************************************************************************
  2. * File: hbox.c
  3. *
  4. * Purpose: Produce a hollow box using asterisk symbol using for loop.
  5. * Author:        Dhilip89
  6. * Date:        9-Oct-09
  7. * Notes:
  8. *                        Write a program using for loops to produce a hollow box using the
  9. *                        asterisk (*) symbol. The program should prompt the user for
  10. *                        the height of the hollow box and check to see that the user
  11. *                        entered a number greater than or equal to 3 and less than or
  12. *                        equal to 40. If the user enters an invalid number, the program
  13. *                        will print an error message and exit. If the user enters a
  14. *                        valid number the program will print a hollow box of height and
  15. *                        width n, where n is the number the user entered at the console.
  16. *
  17. ******************************************************************************/

  18. #include <stdio.h>

  19. int main(void) {

  20.         int iSize, iMin = 3, iMax = 40;
  21.         int i, j;
  22.         printf("Enter the size (Between %d ~ %d): ", iMin, iMax);
  23.         scanf("%d", &iSize);

  24.         if ((iSize >= iMin) && (iSize <= iMax))
  25.         {

  26.                 for (i = 1; i <= iSize; i++)
  27.                 {
  28.                         for (j = 1; j <= iSize; j++)
  29.                         {
  30.                                 if ((i == 1) || (i == iSize))
  31.                                 {
  32.                                         printf("*");
  33.                                 }

  34.                                 else if ((j == 1) || (j == iSize))
  35.                                 {
  36.                                         printf("*");
  37.                                 }
  38.                                 else
  39.                                 {
  40.                                         printf(" ");
  41.                                 }
  42.                         }

  43.                         printf("\n");
  44.                 }

  45.         }
  46.         else
  47.         {
  48.                 printf("Error: Invalid value entered!\n");
  49.         }

  50.         return 0;
  51. }
复制代码
结果:


[ 本帖最后由 Dhilip89 于 2009-10-9 01:46 PM 编辑 ]


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

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

5#
发表于 2009-10-9 04:02 AM |只看该作者

回复 #1 ぁあぃ← 的帖子

不是叫你画金字塔就偷笑了 -.-||| , 我跟你的命运差不多。


回复

使用道具 举报

92

主题

8

好友

4470

积分

一流名嘴

来者何人

Rank: 12Rank: 12Rank: 12

6#
发表于 2009-10-9 09:10 AM |只看该作者

回复 #5 宅男-兜着走 的帖子

谢谢你

不过好像不是这样勒

如果打 1,2

他会整个跳出来~

形成的很像是要

*
**
***
这样的~


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

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

7#
发表于 2009-10-9 09:17 AM |只看该作者

回复 #6 ぁあぃ← 的帖子

你做过哦? -.-||| 老掉。 这个是让人讨厌的东西。 呵呵呵呵。


回复

使用道具 举报

92

主题

8

好友

4470

积分

一流名嘴

来者何人

Rank: 12Rank: 12Rank: 12

8#
发表于 2009-10-9 10:51 AM |只看该作者

回复 #7 宅男-兜着走 的帖子

没有==

烦人的assignment~


回复

使用道具 举报

5

主题

0

好友

320

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

9#
发表于 2009-10-9 10:56 AM |只看该作者
原帖由 ぁあぃ← 于 2009-10-8 10:06 PM 发表
Write a program using for loops to produce a hollow box using the asterisk (*) symbol. The program should prompt the user for the height of the hollow box and check to see that the user entered a ...



是真的有點難度的東西
聽說要用MS visual 6.0寫出來的才算噢
不能用software的~~


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

10#
发表于 2009-10-9 12:23 PM |只看该作者
原帖由 不愛哭の小犬 于 2009-10-9 10:56 AM 发表



是真的有點難度的東西
聽說要用MS visual 6.0寫出來的才算噢
不能用software的~~



何謂 Software?? 那 Visual Studio 6.0 是否是 Software??


回复

使用道具 举报

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

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 09:23 AM , Processed in 0.118522 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部