線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1232
推到 Plurk!
推到 Facebook!

數組存儲

答題得分者是:Stallion
joon
一般會員


發表:35
回覆:41
積分:14
註冊:2004-01-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-01-12 11:12:49 IP:60.176.xxx.xxx 訂閱
需要將0x000042822880492CA00044D60FA048B6E200..........每8位保存到t[i]中,像t[1]=00004282,t[2]=2880492C,。。。。。怎麽保存速度快點;然後t[i]最大能保存多少?謝謝各位。
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-01-12 11:30:45 IP:211.22.xxx.xxx 未訂閱
//---------------------------------------------------------------------------
#include
#pragma hdrstop

#include "Unit1.h"
#include "StrUtils.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
String TempValue, HexValue = "000042822880492CA00044D60FA048B6E200";
int Count, Step = 8;
TStringList *aList;

this->Memo1->Lines->Clear();
try
{
aList = new TStringList;
while ( ( TempValue = LeftStr(HexValue,Step) ).Length() > 0 )
{
aList->Add(TempValue);
HexValue = RightStr(HexValue,HexValue.Length()-Step);
}

for ( Count = 0 ; Count < aList->Count ; Count )
this->Memo1->Lines->Add(aList->Strings[Count]);
}
__finally
{
delete aList;
}

}
//---------------------------------------------------------------------------
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-01-12 11:38:17 IP:61.219.xxx.xxx 未訂閱
最快, 行內組合語言
t[i]最大能保存多少 ? 看您的宣告方式吧, 極限應該是吃盡系統資源 (例如 RAM 用光 or HD 爆滿)
i 值請參考 Help
Static array types are denoted by constructions of the form
array[indexType1, ..., indexTypen] of baseType
where each indexType is an ordinal type whose range does not exceed 2GB. Since the indexTypes index the array, the number of elements an array can hold is limited by the product of the sizes of the indexTypes. In practice, indexTypes are usually integer subranges.
--------
Dynamic arrays do not have a fixed size or length. Instead, memory for a dynamic array is reallocated when you assign a value to the array or pass it to the SetLength procedure. Dynamic-array types are denoted by constructions of the form
--------
procedure SetLength(var S; NewLength: Integer);
Description
S is a Delphi string or dynamic-array variable.
NewLength is the new number of characters or elements in S.
For a short-string variable, SetLength simply sets the length-indicator character (the character at S[0]) to the given value. In this case, NewLength must be a value between 0 and 255.
For a long-string or dynamic-array variable, SetLength reallocates the string or array referenced by S to the given length. Existing characters in the string or elements in the array are preserved, but the content of newly allocated space is undefined. The one exception is when increasing the length of a dynamic array in which the elements are types that must be initialized (strings, Variants, Variant arrays, or records that contain such types). When S is a dynamic array of types that must be initialized, newly allocated space is set to 0 or nil.
For dynamic arrays, SetLength may take more than one length parameter (up to the number of array dimensions). Each parameter specifies the number of elements along a particular dimension.
Following a call to SetLength, S is guaranteed to reference a unique string or arrayhat is, a string or array with a reference count of one. If there is not enough memory available to reallocate the variable, SetLength raises an EOutOfMemory exception.
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
joon
一般會員


發表:35
回覆:41
積分:14
註冊:2004-01-02

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-01-12 16:23:17 IP:60.176.xxx.xxx 訂閱
謝謝兩位,Stallion我原來是0x的數,經你的程式改變了,能不能存為0x.......;0x........;0x.......謝謝~!
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-01-12 16:31:11 IP:211.22.xxx.xxx 未訂閱
上面的字串為為參照你的問題所寫出的範例,不曉得你的十六進位字串是長成怎樣?如果為一串不帶0X開頭的字串的話,在這邊加上去~
aList->Add("0x" TempValue);
===================引 用 文 章===================
謝謝兩位,Stallion我原來是0x的數,經你的程式改變了,能不能存為0x.......;0x........;0x.......謝謝~!
系統時間:2024-05-07 22:42:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!