|
一道算法题,求解。
你的代码有些错误。 int m[2n]={a1,a2,…an,b1,b2,…bn}; int a[n],b[n],i; for(i=0;i<n;i++) a[i]=m[i]; for(i=0;i<2*n-1;i++) //这里会数组下标越界 b[i]=m[i]; for(i=0;i<2*n-1;i++) { if(i%2==0) m[i]=a[i/2+1] else m[i]=b[(i+1)/2]; } |
|
一道算法题,求解。
其实这题也不算排序。 |
|
|
|
一道算法题,求解。
这里的空间复杂度O(1)是指算法的额外空间消耗为常量级别。也就是说,不论我数组是多大,你实现这个功能的算法的额外空间需要是常量数值(可以大于1)。比如楼上的一些朋友另外定义一个b[n]数组,这里的数组长度很明显是跟规模n有关,就不是常量级O(1)了。 |
|
一道算法题,求解。
[QUOTE=djxcon;1171415]a[2n] ={a1,.....,an,b1,.......,bn}; temp; for(i=1;i<n-1;i+=2) { temp = a[i]; a[i] = a[n-1+i]; a[n-1+i] = temp; }[/QUOTE] 你这个算法不能达到题目要求的排列顺序。分析一下循环: 为了避免混淆,数组命名为A[2n] 当 i=1 时 temp = A[1] // A[1]为a2 A[1] = A[n] // A[n]为b1 A[n] = temp 那么这趟循环后的排列为 a1,b1,a3,a4,....,an,a2,b2,b3,...,bn 当 i=3 时 temp = A[3] // A[3]为a[3] A[3] = A[n+2] // A[n+2]为b[3] A[n+2] = A[3] 那么这趟循环后的排列为 a1,b1,a3,b3,...,an,a2,b2,a4,b4,...,bn 依次类推,你会发现这个序列根本就不符合题意。 |
|
一道算法题,求解。
不限。不过一般都是指针。 |
|
一道算法题,求解。
[QUOTE=zLINKo;1171394]int a[2n]={a1,a2,a3,a4,a5,b1,b2,b3,b4,b5}; int b[2n]={0}; //b[2n]={a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,}; int k=0, g=0; for(int i=0,i<2n,i++) { if(i%2=0) ...[/QUOTE] 有一点很明显,那就是空间复杂度不是O(1)。。。 |
|
一道算法题,求解。
[QUOTE=memii;1171436]我是学生,刚学数组,斗胆试一下。 int m[2n]={a1,a2,…an,b1,b2,…bn}; int a[n],b[n],i; for(i=0;i<n;i++) a[i]=m[i]; for(i=0;i<2*n-1;i++) b[i]=m[i]; for(i=0;i<2*n...[/QUOTE] 亲,你的这个算法很明显空间复杂度不符合要求哦 |
|
求助:网上的msdn免积分下载器原理是什么?
这个是源码啊。。。 |
|
求助:网上的msdn免积分下载器原理是什么?
这个不错,测试通过。 |
|
[原创]ring3下的IAT HOOK
刚下载,支持一下。。 |
|
[求助]软件加壳后怎么才能避过杀软的误报?
现在的杀毒大多数360的天下,把软件提交给360认证下就行了。。。 |
|
[原创]MrleeProtect游戏保护
谢了,稍后试试 |
|
[原创]MrleeProtect游戏保护
知道需要哪些工具大概就能搭建起来啦,视频太大不方便共享- - |
|
[原创]MrleeProtect游戏保护
单机调试会不会比双机调试要方便些? |
|
|
|
[原创]MrleeProtect游戏保护
在编译驱动的时候出现错误。。。我是WinXP SP3和VS2010,是怎么回事?难道是我环境不对么。。 1>------ 已启动生成: 项目: MrleeProtect, 配置: Debug Win32 ------ 1>生成启动时间为 2013-2-25 15:08:16。 1>Build: 1> 系统找不到指定的路径。 1> 'build' 不是内部或外部命令,也不是可运行的程序 1> 或批处理文件。 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: 命令“call \bin\setenv.bat chk wxp 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: cd /d E:\MrleeProtect\ 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: build”已退出,代码为 9009。 1> 1>生成失败。 1> 1>已用时间 00:00:00.06 ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ========== |
操作理由
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 }}
勋章
兑换勋章
证书
证书查询 >
能力值