小编ken*_*ytm的帖子

代码没有编译

//cstack.h
# ifndef _STACK_H__
#define _STACK_H__

#include<iostream>
#include<vector>

template< class Type ,int Size = 3>
class cStack
{
 Type *m_array;
 int m_Top;
 int m_Size;

public:
    cStack();
    cStack(const Type&);
    cStack(const cStack<Type,Size> &);
    int GetTop()const;
    bool Is_Full()const;
    bool Is_Empty()const;
    void InsertValue(const Type&);
    void RemeoveValue();
    void show();  
    ~cStack();
    friend std::ostream& operator <<(std::ostream &, const cStack<Type,Size> &);
};

// iam writing only one function defination because linking is because of this function
template< class Type,int Size >
std::ostream& operator << ( std::ostream &os, const …
Run Code Online (Sandbox Code Playgroud)

c++ linker-errors

0
推荐指数
1
解决办法
2408
查看次数

变量变量

如何在for循环中创建变量?

这是循环:

for ( $counter = 1; $counter <= $aantalZitjesBestellen; $counter ++) {

}
Run Code Online (Sandbox Code Playgroud)

在这个循环中我想为每次传递创建一个变量$ seat,但它必须增加如此.第一次它通过它应该是$seat1 = $_POST['seat'+$aantalZitjesBestellen],下次它通过:$seat2 = $_POST['seat'+$aantalZitjesBestellen]等等.

所以最后它应该是:

$seat1 = $_POST['seat1'];
$seat2 = $_POST['seat2'];
Run Code Online (Sandbox Code Playgroud)

等等.

所以$ _POST的变量和内容应该是动态的.

php

0
推荐指数
1
解决办法
367
查看次数

gdb和strncmp,寄存器值存储了吗?

以下是我的代码(test.c):

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {

 char passwd[] = "pass";

 if (argc < 2) {
        printf("usage: %s <given-password>\n", argv[0]);
        return 0;
 }

 if (!strncmp(passwd, argv[1],4)) {
        printf("Green light!\n");
        return 1;
 }

 printf("Red light!\n");
 return 0;
}
Run Code Online (Sandbox Code Playgroud)

我编译使用:

  gcc -o test test.c

    And I started debugger: `gdb ./test`
    (gdb) disassemble main
    Dump of assembler code for function main:
    0x08048404 <main+0>:    lea    0x4(%esp),%ecx
    ......
    0x08048456 <main+82>:   mov    0x4(%edx),%eax
    0x08048459 <main+85>:   add    $0x4,%eax
    0x0804845c <main+88>:   mov    (%eax),%eax
    0x0804845e …
Run Code Online (Sandbox Code Playgroud)

gdb

0
推荐指数
1
解决办法
1550
查看次数

终止充满垃圾的字符串?

C是否允许在读取字节的末尾放置一个字符串终止符,或者仅在读取的字节是字符时才能保证?

我需要从stdin读取类似的东西,但我不知道要读取多少个字符并且不能保证EOF:

Hello World!---full of garbage until 100th byte---
Run Code Online (Sandbox Code Playgroud)
char *var = malloc(100 + 1);

read(0, var, 100); // read from stdin. Unfortunately, I do not know how many bytes to read and stdin is not guaranteed to hold an EOF. (I chose 100 as an educated guess.)

var[100] = '\0'; // Is it possible to place a terminator at the end if most of the read bytes are garbage ?
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
168
查看次数

解释Ruby Commify大整数方法

我在网上发现了这个片段,其目的是为了包括带小数的数字的任何数字... 99999999 => 99,999,999.我可以看到它使用正则表达式,但我对"$ 1.reverse,$ 2"感到困惑

def commify(n)
  n.to_s =~ /([^\.]*)(\..*)?/
  int, dec = $1.reverse, $2 ? $2 : ""
  while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3')
  end
  int.reverse + dec
end
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释这段代码中发生了什么?

ruby regex

0
推荐指数
2
解决办法
484
查看次数

新手数字范围的正则表达式问题

我真的应该优化我的正则表达式,但现在任何人都可以帮助...

((2,3,4,11,8),(5,44,67,78,32,22,111,234))
Run Code Online (Sandbox Code Playgroud)

如您所见,每个数字范围都以逗号分隔,在此示例中,有两个数字范围.

在实际场景中,可能有许多数字和少数范围.

所以...我如何将这样的东西提取到php嵌套数组或类似的东西?

任何帮助表示感谢

php regex

0
推荐指数
1
解决办法
114
查看次数

objective c,检查对象是否未定义或为零

好的,我创建了自己的类(MyObject)子类NSObject

然后在我的代码中我声明:

MyObject * myObject;
Run Code Online (Sandbox Code Playgroud)

然后我的功能进一步向下,我做:

if(myObject == nil)
{
 myObject = [self getObject];
}
Run Code Online (Sandbox Code Playgroud)

我的if语句返回false,我希望它是真的.

在调试模式下:只是声明它正在使用一些随机值为其分配实例.那么,我是否必须覆盖init函数,以便返回nil,然后创建自己的initWith函数?

objective-c

0
推荐指数
1
解决办法
1337
查看次数

混淆了setTimeout和clearTimeout

我有一个按钮,当它翻转时会改变div的背景.后台需要在计时器上更改,所以我使用setTimout来执行更改背景的方法.我认为clearTimeout会取消和我设置的超时,所以我把它放在mouseleave事件上.然而它似乎并没有停止超时.我的逻辑在这吗?

$("#h2Buzz").mouseenter(function () {   
   setTimeout(playV(), 2700);
   setTimeout(playP(), 5400);
}); 
$("#h2Buzz").mouseleave(function () {
   clearTimeout(playV());
   clearTimeout(playP());
});


function playV() {
    $("#ServicesBackgroundImage2").css("background-image", "url(/images/v.jpg)");
}
function playPn() {

    $("#ServicesBackgroundImage2").css("background-image", "url(/images/p.jpg)");
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery settimeout

0
推荐指数
2
解决办法
2856
查看次数

C++标准问题

如果以下结果导致未定义的行为?

应该指针2的值为NULL吗?

double *pointer = 0;
double &value = *pointer;
double *pointer2 = &value;
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
168
查看次数

Java:简单组合k顺序的一组元素

我有一组数字{'1','13','25','32','49',...},我想计算这个数量k的所有可能组合.

Esample1:

set = {'1','5','23','41,'54','63'};
k = 4;
Run Code Online (Sandbox Code Playgroud)

输出1:

1 5 23 41
1 5 23 54
1 5 23 63
1 5 41 54
1 5 41 63
1 5 54 63
1 23 41 54
1 23 41 63
1 23 54 63
1 41 54 63
5 23 41 54
5 23 41 63
5 23 54 63
5 41 54 63
23 41 54 63
Run Code Online (Sandbox Code Playgroud)

例2:

set = {'a','v','f','z'};
k=3;
Run Code Online (Sandbox Code Playgroud)

输出2:

a v f …
Run Code Online (Sandbox Code Playgroud)

java combinations

0
推荐指数
1
解决办法
2667
查看次数

标签 统计

c++ ×2

php ×2

regex ×2

c ×1

combinations ×1

gdb ×1

java ×1

javascript ×1

jquery ×1

linker-errors ×1

objective-c ×1

ruby ×1

settimeout ×1