Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
12
返回列表 发新帖
楼主: 小蠢
打印 上一主题 下一主题

谁来帮帮我~C程式!!(急)

[复制链接]

46

主题

6

好友

6456

积分

百变名嘴

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

11#
发表于 2009-10-28 09:12 PM |只看该作者

回复 #6 Super-Tomato 的帖子

看到腻了~ 还好没人问 hello world 怎么写。


回复

使用道具 举报

62

主题

5

好友

3715

积分

本站名嘴

Rank: 11Rank: 11

12#
发表于 2009-10-28 09:27 PM |只看该作者

回复 #8 Dhilip89 的帖子

前面为什么要int i?


回复

使用道具 举报

2

主题

0

好友

6008

积分

百变名嘴

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

13#
发表于 2009-10-28 09:48 PM |只看该作者

回复 #12 goodhermit95 的帖子

declare i 呀
如果不预先declare
也可以这样写
for(int i = 0; i <= 100; i++|){
打列******出来
}

也可以
int i;
for( i =0; i <= 100; i++){
bla bla bla
}


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

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

14#
发表于 2009-10-28 10:40 PM |只看该作者

回复 #13 毛毛小子 的帖子

太正统了~ 某些语言什么都不必 declare。

直接 for(i=0 ; ...;... )

这样就可以了~ 多爽。


回复

使用道具 举报

3

主题

0

好友

2953

积分

白金长老

Rank: 10

15#
发表于 2009-10-29 07:56 AM |只看该作者
原帖由 goodhermit95 于 2009-10-28 09:27 PM 发表
前面为什么要int i?


因为要 declare variable 啊em0051

我在 for loop 外面 declare 的原因是我用的 cl.exe 不支持 ANSI C99 Standard.

  1. #include <stdio.h>

  2. int main()
  3. {

  4.         for (int i = 1; i <= 100; i++)
  5.                 i % 10 == 0 ? printf("\n") : printf("*");

  6.         return 0;
  7. }
复制代码

  1. C:\Users\Dhilip89\Desktop>cl star.c
  2. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
  3. Copyright (C) Microsoft Corporation.  All rights reserved.

  4. star.c
  5. star.c(6) : error C2065: 'i' : undeclared identifier
  6. star.c(6) : error C2065: 'i' : undeclared identifier
  7. star.c(6) : error C2065: 'i' : undeclared identifier
  8. star.c(7) : error C2065: 'i' : undeclared identifier

  9. C:\Users\Dhilip89\Desktop>cl star.c
  10. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
  11. Copyright (C) Microsoft Corporation.  All rights reserved.

  12. star.c
  13. star.c(6) : error C2065: 'i' : undeclared identifier
  14. star.c(6) : error C2065: 'i' : undeclared identifier
  15. star.c(6) : error C2065: 'i' : undeclared identifier
  16. star.c(7) : error C2065: 'i' : undeclared identifier
复制代码

  1. #include <stdio.h>

  2. int main()
  3. {
  4.         int i;

  5.         for (i = 1; i <= 100; i++)
  6.                 i % 10 == 0 ? printf("\n") : printf("*");

  7.         return 0;
  8. }
复制代码
  1. C:\Users\Dhilip89\Desktop>cl star.c
  2. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
  3. Copyright (C) Microsoft Corporation.  All rights reserved.

  4. star.c
  5. Microsoft (R) Incremental Linker Version 9.00.30729.01
  6. Copyright (C) Microsoft Corporation.  All rights reserved.

  7. /out:star.exe
  8. star.obj

  9. C:\Users\Dhilip89\Desktop>star
  10. *********
  11. *********
  12. *********
  13. *********
  14. *********
  15. *********
  16. *********
  17. *********
  18. *********
  19. *********
复制代码


回复

使用道具 举报

62

主题

5

好友

3715

积分

本站名嘴

Rank: 11Rank: 11

16#
发表于 2009-10-29 09:36 AM |只看该作者

回复 #15 Dhilip89 的帖子

我没注意到他没有(int i = 0)


回复

使用道具 举报

3

主题

0

好友

2953

积分

白金长老

Rank: 10

17#
发表于 2009-10-29 05:38 PM |只看该作者

回复 #16 goodhermit95 的帖子

我在学院才刚刚上到C Programming的课em0031


回复

使用道具 举报

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

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

GMT+8, 2024-10-25 10:37 PM , Processed in 0.100648 second(s), 21 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.
回顶部