PCDVD數位科技討論區
PCDVD數位科技討論區   註冊 常見問題 標記討論區為已讀

回到   PCDVD數位科技討論區 > 其他群組 > 疑難雜症區
帳戶
密碼
 

  回應
 
主題工具
Sleepyhead
Regular Member
 

加入日期: Sep 2003
您的住址: Taipei
文章: 89
引用:
作者嚐起來像雞
Borland 非常肥大,啟動很慢....
寫命令列的我都用VC 6....
可是VC6有個大BUG....
for ( int i=0; i<2; i++ )
{
//...
}
int i=0; //VC顯示錯誤

很明顯地第一個i 是個區塊變數 (= = 可以這樣叫嗎),
生於for,死於for,
第二個i宣告時VC會跟你說變數重複宣告....
很鳥!

我用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
回應時引用此文章
Sleepyhead離線中  
harrisonlin
Advance Member
 
harrisonlin的大頭照
 

加入日期: 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
回應時引用此文章
harrisonlin離線中  
Tirpitz
Master Member
 
Tirpitz的大頭照
 

加入日期: Apr 2001
您的住址: Coruscant
文章: 1,637
引用:
作者vanness70087
我可以把cout改成printf嗎~~???
因為COUT的指令還沒交~~~~!!
ENDL是結束的意思嗎~???


很多大大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
回應時引用此文章
Tirpitz離線中  
axbycz
Power Member
 
axbycz的大頭照
 

加入日期: Jun 2004
文章: 574
引用:
作者Tirpitz
很多大大PO的程式碼已經不是純C的語法了吧?...

會害人...

你還是研究一下書吧

你是說這一個嗎? :
#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
回應時引用此文章
axbycz離線中  
axbycz
Power Member
 
axbycz的大頭照
 

加入日期: Jun 2004
文章: 574
引用:
作者vanness70087
我可以把cout改成printf嗎~~???
因為COUT的指令還沒交~~~~!!
ENDL是結束的意思嗎~???

借一下 Wallace 兄的程式
#include <iostream>
using namespace std;
int main() {
int total=9;
for (int i=1;i<=total;i++) {
int curr_no=(i<=(total/2)) ? i:total-i+1;
for (int j=1;j<=curr_no;j++) {
printf("*");
}
printf("\n");
}
return 0;
}
__________________
雨之為物 能令晝短 能令夜長

此文章於 2005-04-01 08:05 AM 被 axbycz 編輯.
舊 2005-04-01, 08:03 AM #55
回應時引用此文章
axbycz離線中  
axbycz
Power Member
 
axbycz的大頭照
 

加入日期: Jun 2004
文章: 574
引用:
作者PAN_PAN
找台不要的電腦裝 Linux 或 FreeBSD
一裝好應該就有 g++ 可以用了

謝謝你
我是忠實愛用者
Linux 的開發環境真的比 M$ 好很多
__________________
雨之為物 能令晝短 能令夜長
舊 2005-04-01, 08:09 AM #56
回應時引用此文章
axbycz離線中  
chou121
*停權中*
 

加入日期: 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
回應時引用此文章
chou121離線中  
ahdeng
Junior Member
 
ahdeng的大頭照
 

加入日期: Aug 2002
您的住址: 「天龍國」
文章: 795
大家討論那麼多,不論是從compile environment或compile tools,
但最主要的是「誰可以幫我寫出一個簡單的程式....QQ~! 」
還是printf最簡單:jolin :jolin
__________________
「千金難買早知道,萬般無奈想不到。」
舊 2005-04-01, 09:16 AM #58
回應時引用此文章
ahdeng離線中  
vanness70087
Advance Member
 

加入日期: Jan 2005
文章: 469
我用你們寫的程式去學校跑~
沒有一個是對的= =
美一個錯誤都在5個以上~瘋掉~!
舊 2005-04-01, 05:28 PM #59
回應時引用此文章
vanness70087離線中  
ahdeng
Junior Member
 
ahdeng的大頭照
 

加入日期: Aug 2002
您的住址: 「天龍國」
文章: 795
忘了提醒你,
寫程式不用很多時間,
因為大部份都花在debug!!
__________________
「千金難買早知道,萬般無奈想不到。」
舊 2005-04-01, 06:13 PM #60
回應時引用此文章
ahdeng離線中  


    回應


POPIN
主題工具

發表文章規則
不可以發起新主題
不可以回應主題
不可以上傳附加檔案
不可以編輯您的文章

vB 代碼打開
[IMG]代碼打開
HTML代碼關閉



所有的時間均為GMT +8。 現在的時間是11:07 PM.


vBulletin Version 3.0.1
powered_by_vbulletin 2024。