Regular Member
加入日期: Sep 2003 您的住址: Taipei
文章: 89
|
引用:
我用MS Visual Studio 2003 裡的 VC.NET(7.0) 試過了, 已經不會出現error了,執行也正確, 但在default warning level 3下,還是會給個warning: warning C4288: nonstandard extension used : 'i' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope |
||||||||
2005-03-31, 07:07 PM
#51
|
Advance Member
加入日期: Jun 2003 您的住址: Taipei
文章: 442
|
參與一下漏斗型的討論:
代碼:
#include "iostream" using namespace std; void main() { for(int y = 0; y < 7; ++y) { for(int x = 0; x < 7; ++x) { if(y <= 3) { if((y == 0) || ((x >= y) && ((x + y) <= 6))) { cout << "*"; } else { cout << " "; } } else { if((y == 0) || ((x <= y) && ((x + y) >= 6))) { cout << "*"; } else { cout << " "; } } } cout << endl; } }
__________________
現今世道,自爆文當故事書,站長的話做成語錄,幾百年前的文章嘛沒事就挖出來考古... 此文章於 2005-03-31 07:46 PM 被 harrisonlin 編輯. |
||
2005-03-31, 07:42 PM
#52
|
Master Member
加入日期: Apr 2001 您的住址: Coruscant
文章: 1,637
|
引用:
很多大大PO的程式碼已經不是純C的語法了吧?... 會害人... 你還是研究一下書吧
__________________
Un Jedi ne doit connaitre ni la colere, ni la haine, ni l'amour. Someday I will be the most powerful Jedi ever~!! Jedi Code there is no emotion;there is the peace there is no ignorance;there is the knowledge there is no passion;there is the serenity there is no death;there is the Force 此文章於 2005-03-31 09:20 PM 被 Tirpitz 編輯. |
|
2005-03-31, 09:18 PM
#53
|
Power Member
加入日期: Jun 2004
文章: 574
|
引用:
你是說這一個嗎? : #include <iostream> using namespace std; int main() { int y; for(y=0; y<1; y++) { cout<<"*"<<endl; cout<<"**"<<endl; cout<<"***"<<endl; cout<<"****"<<endl; cout<<"*****"<<endl; cout<<"****"<<endl; cout<<"***"<<endl; cout<<"**"<<endl; cout<<"*"<<endl; } return 0; }
__________________
雨之為物 能令晝短 能令夜長 |
|
2005-04-01, 07:48 AM
#54
|
Power Member
加入日期: Jun 2004
文章: 574
|
引用:
借一下 Wallace 兄的程式 #include <iostream> using namespace std; int main() { int total=9;}
__________________
雨之為物 能令晝短 能令夜長 此文章於 2005-04-01 08:05 AM 被 axbycz 編輯. |
|
2005-04-01, 08:03 AM
#55
|
Power Member
加入日期: Jun 2004
文章: 574
|
引用:
謝謝你 我是忠實愛用者 Linux 的開發環境真的比 M$ 好很多
__________________
雨之為物 能令晝短 能令夜長 |
|
2005-04-01, 08:09 AM
#56
|
*停權中*
加入日期: May 2001 您的住址: Taipei
文章: 22
|
純 C 的程式
#include <stdio.h> #ifdef __cplusplus extern "C" { #endif #define ROWCnt 9 void Case1() { int rowIdx; int idx, starCnt; printf("Case 1:\n"); for (rowIdx = 0; rowIdx < ROWCnt; rowIdx++) { starCnt = ((rowIdx < ROWCnt / 2) ? rowIdx + 1 : ROWCnt - rowIdx); for (idx = 0; idx < starCnt; idx++) printf("*"); printf("\n"); } printf("\n"); } void Case2() { int rowIdx; int idx, spaceCnt, starCnt; printf("Case 2:\n"); for (rowIdx = 0; rowIdx < ROWCnt; rowIdx++) { spaceCnt = ((rowIdx < ROWCnt / 2) ? rowIdx : ROWCnt - rowIdx - 1); starCnt = ROWCnt - 2 * spaceCnt; for (idx = 0; idx < spaceCnt; idx++) printf(" "); for (idx = 0; idx < starCnt; idx++) printf("*"); printf("\n"); } printf("\n"); } int main() { Case1(); Case2(); return 0; } #ifdef __cplusplus } #endif |
2005-04-01, 09:10 AM
#57
|
Junior Member
加入日期: Aug 2002 您的住址: 「天龍國」
文章: 795
|
大家討論那麼多,不論是從compile environment或compile tools,
但最主要的是「誰可以幫我寫出一個簡單的程式....QQ~! 」 還是printf最簡單:jolin :jolin
__________________
「千金難買早知道,萬般無奈想不到。」 |
2005-04-01, 09:16 AM
#58
|
Advance Member
加入日期: Jan 2005
文章: 469
|
我用你們寫的程式去學校跑~
沒有一個是對的= = 美一個錯誤都在5個以上~瘋掉~! |
2005-04-01, 05:28 PM
#59
|
Junior Member
加入日期: Aug 2002 您的住址: 「天龍國」
文章: 795
|
忘了提醒你,
寫程式不用很多時間, 因為大部份都花在debug!!
__________________
「千金難買早知道,萬般無奈想不到。」 |
2005-04-01, 06:13 PM
#60
|