|
|
|
[求助]电脑速度慢是不是和CPU的转速有关?
当你喝醉了,就会发现cpu比以前转的快多了。 |
|
[讨论]C结构体对齐方式
pragma也是静态对齐的吧。没做试验。不过好像没见过机制能让操作系统在载入的时候动态改变程序的变量对齐。重定位估计也会费些劲。 |
|
[原创]质因数分解C版
修改一下。刚刚写错了.应该是空间压缩30倍. |
|
尋找 1 到指定正整數之間所有的質數--Using C by 梵听版
AsmDebuger 的写法优化就是 if( table[k] == 0 ) { for( long j=k+k+k; j< NUM; j+=k+k) { table[j] = 1;//若为合数,数值变为1 } } |
|
尋找 1 到指定正整數之間所有的質數--Using C by 梵听版
如果不顾及空间只为了速度。稍作了一下优化 但是感觉空间浪费还是有点过。有15/16的空间没用。 #include "stdio.h" #include "math.h" #define NUM 5000 void suShu() { bool* table = new bool[NUM+1]; //int numbers = 0; for([COLOR="Red"]register [/COLOR]long [COLOR="Red"]i=1[/COLOR]; i<=NUM; [COLOR="red"]i++,i++)[/COLOR] { table[i] = 0;//初始化数组 } long halfNum = (long)sqrt(NUM);//因数最大值 for([COLOR="Red"]register[/COLOR] long [COLOR="red"]k=3[/COLOR]; k<=halfNum; [COLOR="red"]k++,k++ )[/COLOR] { if( table[k] == 0 ) { long l = NUM/k; for( long [COLOR="red"]j=3;[/COLOR] j<= l; [COLOR="red"]j++,j++)[/COLOR] { table[k*j] = 1;//若为合数,数值变为1 } } } [COLOR="red"] printf("%12d",2);[/COLOR] for([COLOR="Red"]register [/COLOR]long [COLOR="red"]l=3; [/COLOR]l<=NUM;[COLOR="red"] l++,l++)[/COLOR] { if(table[l] == 0) { //numbers++; printf("%12d",l); } } } int main() { suShu(); return 0; } |
|
尋找 1 到指定正整數之間所有的質數--Using C by 梵听版
空间上也没有省太多。一般编译器仍然把bool用1byte而不是bite。 实测这个程序在VC9下编译运行内存是49M 要高效的话还是内联汇编把。不过移植性差。 |
|
|
|
|
|
[求助]数字签名问题
恩,这是没区别的。(都对明文进行这也不算先后啊。算同时把。呵呵)估计是我表述错误。 不过还是感谢arab。 ------ 有一种情况(之接受指定目标的信息)需要对加密后的数据签名。比如 假设有一天高考试题用网络的话 出题的机构对试题加密后签名。 在考试当天发布解密密匙。 这样每个考场需要在解密之前确定试题来自出题机构。这里不存在仿冒的成分。有人仿冒考场也不会理之。 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值