全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:774
推到 Plurk!
推到 Facebook!

請問StringGrid之顯示問題???

答題得分者是:Zard
Vincent2424
一般會員


發表:57
回覆:40
積分:19
註冊:2004-12-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-30 16:49:45 IP:163.25.xxx.xxx 未訂閱
請問各位... 我利用StringGrid來show計算結果.... 程式如下:    void __fastcall TForm1::Button3Click(TObject *Sender) {       R=StrToFloat(Edit4->Text);//6    n=StrToFloat(Edit5->Text);//10    h_max=StrToFloat(Edit6->Text);//9       //計算k    k=R/n;        for(i=1; i<=n; i++)    {         for(j=0; j<=h_max; j++)         {       //計算半徑(r)    r=i*k;       //計算X值、Y值    X=(-0.408399)*pow(r,3)+(6.6646)*pow(r,2)+(-35.0125)*r+65.9293;       Y=2*j;       StringGrid1->Cells[0][i]=IntToStr(i);    StringGrid1->Cells[1][i]=FloatToStr(r);    StringGrid1->Cells[2][i]=FloatToStr(X);    StringGrid1->Cells[3][i]=FloatToStr(Y);       }       }    }    跑出來的如下圖: 似忽只有show出外面的loop,裡面的loop沒show出.... 正確應該如下圖: 請問各位大大我該如何改程式才能正確show出兩個loop的值呢..???
ldd
一般會員


發表:12
回覆:62
積分:19
註冊:2004-07-06

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-30 17:09:06 IP:59.120.xxx.xxx 未訂閱
也許你可以試試看 Debug h_max的值....
Zard
尊榮會員


發表:24
回覆:396
積分:539
註冊:2003-11-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-30 17:30:36 IP:210.243.xxx.xxx 未訂閱
修改你的loop如下面紅字所示
  for(i=1; i<=n; i  )
  {
    for(j=0; j<=h_max; j  )
    {
      //計算半徑(r)
      r=i*k;          //計算X值、Y值
      X=(-0.408399)*pow(r,3) (6.6646)*pow(r,2) (-35.0125)*r 65.9293;          Y=2*j;
      
      StringGrid1->Cells[0][(i - 1)*h_max   j   1]=IntToStr(i);
      StringGrid1->Cells[1][(i - 1)*h_max   j   1]=FloatToStr(r);
      StringGrid1->Cells[2][(i - 1)*h_max   j   1]=FloatToStr(X);
      StringGrid1->Cells[3][(i - 1)*h_max   j   1]=FloatToStr(Y);
      
    }
  }
Vincent2424
一般會員


發表:57
回覆:40
積分:19
註冊:2004-12-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-12-30 22:15:45 IP:219.84.xxx.xxx 未訂閱
我瞭解囉~~~ 感謝你Zard~~~tks~~
系統時間:2024-05-18 18:29:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!