欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
自創排序法
[打印本頁]
作者:
liuda
時間:
2015-1-20 01:37
標題:
自創排序法
覺得有缺點點請告訴我
C語言代碼:
char s[30],sd[11],i,j;若為了減少變量在RAM中占的空間在char后加xdata即可,但程序代碼段會增加字節
char code a[]={17,2,6,12,23,2,3,4,21,9,5};//code是為了代碼空間占用少,不加會多次2百左右字節,所以上面加了個存放數組
for(i=0;i<sizeof(a);i++)
{
s[a
]++;
}
//循環數組
for(i=0;i<sizeof(s);i++)
{
//將排好的數覆蓋到原數組,當有重復的下標加1,數組對應的值減1
while(s
)
{
sd[j]=i;
j++;
s
--;
}
}
Program Size: data=51.0 xdata=0 code=84
代碼執行總時間為393us。
若char xdata s[30],sd[11],i,j;
Program Size: data=9.0 xdata=43 code=169
C#代碼:
string value="";
int[] s = new int[30];
int i, j = 0;
int[] a = { 17, 2, 6, 12, 23, 2, 3, 4, 21, 9, 5 };
for (i = 0; i < 11; i++)
{
s[a
]++;
}
//循環數組
for (i = 0; i < 30; i++)
{
//將排好的數覆蓋到原數組,當有重復的下標加1,數組對應的值減1
while (s
> 0)
{
a[j] = i;//將原數組變為排序后的內容
s+=i.ToString()+" " ;
j++;
s
--;
}
}
MessageBox.Show(value) ;
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1