我想在某个区域内来回水平制作div动画.我现在面临的问题是,我无法弄清楚如何让我的div在向前移动之后向前移动.
这是我正在使用的脚本:
<script type="text/javascript">
var animatethis = function (targetElement, speed) {
$(targetElement).animate(
{
marginLeft: "+=250px"
},
{
duration: speed,
complete: function () {
animatethis(this, speed);
animatethis.stop();
$(targetElement).animate({ marginLeft: "-=250px" });
}
}
)
};
animatethis($('#q1'), 5000);
</script>
Run Code Online (Sandbox Code Playgroud) 我正在玩fgetc并且想知道如何让我的循环打印出行部分然后打印前16个字符.
这是我的代码:
int main(int argc, char * argv[])
{
FILE *fp;
if((fp = fopen(argv[1], "rb+")) == '\0')
{
perror("fopen");
return 0;
}
getchar(fp);
return 0;
}
void getchar(FILE *fp)
{
int c;
size_t linecount = 0;
while((c = fgetc(fp)) != EOF)
{
printf("line : ");
printf("%c ", c);
linecount++;
if(linecount == 16)
{
printf("\n");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想我的输出是这样的:
line: ? 5 d s d a d 0 0 0 0 0 0 0 0 0 0 0
line: a d …Run Code Online (Sandbox Code Playgroud) 我正在玩模板,我想知道为什么我使用模板得到一个不匹配的函数错误.
/*selection sort*/
template <typename InputIterator, typename T>
void selection_sort(InputIterator first, InputIterator last){
InputIterator min;
for(; first != last - 1; ++first){
min = first;
for(T i = (first + 1); i != last ; ++i)
{
if(*first < *min)
min = i;
}
myswap(*first, *min);
}
}
int main(){
int a[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
vector<int> v(a, a+10);
selection_sort(v.begin(),v.end());
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码将转义字符打印为字符或字符串:
while((c = fgetc(fp))!= EOF)
{
if(c == '\0')
{
printf(" \0");
}
else if(c == '\a')
{
printf(" \a");
}
else if(c == '\b')
{
printf(" \b");
}
else if(c == '\f')
{
printf(" \f");
}
else if(c == '\n')
{
printf(" \n");
}
else if(c == '\r')
{
printf(" \r");
}
else if(c == '\t')
{
printf(" \t");
}
else if(c == '\v')
{
printf(" \v");
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试它时,它实际上打印了转义序列.
c ×2
fgetc ×2
ansi-escape ×1
c++ ×1
jquery ×1
selection ×1
sorting ×1
template-argument-deduction ×1
templates ×1