我找到了python的答案,但我不明白.
代码是修改后的合并排序.对于我检查到的少量输入,它工作得很好.但是当我通过在线判断运行时,当输入数量很高(500)时,它给了我这个错误:
Error in 'a.out': corrupted size vs. prev_size: 0x0000000000d5b8b0
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f3b83a5b7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x80dfb)[0x7f3b83a64dfb]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f3b83a6853c]
a.out[0x4009d1]
a.out[0x400ac7]
a.out[0x400a87]
a.out[0x400aa4]
a.out[0x400a87]
a.out[0x400bc7]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f3b83a04830]
a.out[0x4005b9]
======= Memory map: ========
Run Code Online (Sandbox Code Playgroud)
它还有15行.为什么我收到此错误?是因为我在使用动态分配内存时遇到的一些错误malloc
?
这是我的代码:
#include <stdio.h>
#include <stdlib.h>
void *Merge(int *A,int l,int m,int r,int *B,int *F);
void *Merge(int *A,int l,int m,int r,int *B,int *F){
int i=l,j=m,k=0,*C,x,y=l,z,cSize,temp,*D,*E;
cSize = r-l;
C = (int *) malloc (cSize * sizeof(int));
D = (int *) malloc (cSize * sizeof(int));
E = (int *) malloc (cSize * …
Run Code Online (Sandbox Code Playgroud) 我试图让一个 div 在点击时平滑地扩展到全屏。我想要的最终产品类似于用户在此网站上单击案例研究https://infinum.co/
到目前为止,我的代码可以使 div 全屏显示,但由于我添加的位置固定而跳转。我不担心实际动画是由 CSS 还是 JavaScript/jQuery 处理的。
$(function() {
$(".block").on("click", function() {
$(this).addClass("fullscreen");
});
});
Run Code Online (Sandbox Code Playgroud)
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
.block {
width: 50%;
margin: 0 auto 50px auto;
height: 300px;
background-color: red;
transition: all 0.5s linear;
}
.block.fullscreen {
position: fixed;
top: 0;
width: 100%;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="block"></div>
<div class="block"></div>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我所拥有的一切都可以在这支笔上找到:http : //codepen.io/anon/pen/RKGeYj
所以我有这段代码:
function show_all()
{
document.getElementByClassName('login').style.display = 'inline';
document.getElementById('button-hide').style.display = 'inline';
document.getElementById('button-show').style.display = 'none';
};
function hide_all()
{
document.getElementByClassName('login').style.display = 'none';
document.getElementById('button-hide').style.display = 'none';
document.getElementById('button-show').style.display = 'inline';
};
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav>
<input type="button" value="Show login Buttons" id="button-show" onclick="show_all();"/>
<input type="button" value="Hide login Buttons" id="button-hide" onclick="hide_all();"/>
</nav>
<p class="login">Username:</p>
<img src="un.png" class="login"/>
<p class="login">Password:</p>
<p>Something not ment to be hidden.</p>
<img src="pass.png" class="login"/>
Run Code Online (Sandbox Code Playgroud)
而且我需要显示/隐藏整个班级;我有大约50个带有“登录”类元素的块,我只想使用JavaScript来显示它。