小编Itz*_*984的帖子

在java中使用的正确数据结构是什么?

我想在数据结构中保存整数,但不知道我可能得到的整数的数量.我希望数据库是FIFO类型.什么是最好的目的?

java database fifo

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

分段错误我无法弄清楚

我有以下构造函数:

    Timing::Timing():
    _numMes(INIT_NUMMES),_msgs(new allMSgs*[NUMBER_OF_MSGS])
    {

        cout<<"build timing OK\n";
    }
Run Code Online (Sandbox Code Playgroud)

allMSgs是一个结构:

   typedef struct AllMSgs
   {
            double msg;
        Agent* dedicatedTo;
   }allMSgs;
Run Code Online (Sandbox Code Playgroud)

它的声明是这样完成的:

        allMSgs** _msgs;
Run Code Online (Sandbox Code Playgroud)

但是当我尝试像这样到达阵列中的一个字段时:

     _msgs[loc]->dedicatedTo=agent->getPointsTo();
Run Code Online (Sandbox Code Playgroud)

我得到了分段错误.

NUMBER_OF_MSGS是1000

loc是0,1,2 ....(小于1000);

请帮忙

c++ error-handling

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

从HTML调用函数我javascript

新的js/html所以需要帮助.

我有这个简单的html文件:

   <html>

   <script type="text/javascript" src="rps.js">

   var numOfRounds = 25;
   var result = startGame(numOfRounds,player1,player2 );
   document.write(result.p1+":"+result.p2);

   </script>

   </html>
Run Code Online (Sandbox Code Playgroud)

正如你可以看到我调用的函数是startGame(...)

这是功能:

   function startGame(rounds, player1, player2) {

       var counter = 0;
       while (counter < rounds) {
       player1.itemChosen = player1.play();
       player2.itemChosen = player2.play();

      player1.feedback(player2.itemChosen);
      player2.feedback(player1.itemChosen);

      counter++;
   }
   return  {p1: player1.getW(),p2: player2.getW() }

  };
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,当我尝试调试它(chrome)时,根本没有调用startGame函数.

有任何想法吗?

html javascript

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

html cookie中密钥和值之间有什么区别?

html cookie中密钥和值之间有什么区别?

我在html请求中看到cookie看起来像这样:

  not like this:
    Cookie: name1=key1; name2=key2;

  but rather like this:
   Cookie: key1=value1; key2=value2; 
Run Code Online (Sandbox Code Playgroud)

如果想为每个cookie创建一个唯一的个人ID,请说"UUID",

我应该写key ="UUID"吗?或值="UUID"?

我很抱歉"愚蠢"的问题,但我真的很困惑...

谢谢!

html javascript cookies httpcookie

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

切换字符串c语言

我有这个程序,我想了解以下输出:

#include <stdio.h> 
void fastSwap (char **i, char **d) 
{ 
  char *t = *d; 
  *d = *i; 
  *i = t; 
} 
int main () 
{ 
 char num1[] = "hellohello"; 
 char num2[] = "classclass"; 
 fastSwap ((char**)&num1,(char**)&num2); 
 printf ("%s\n",num1); 
 printf ("%s\n",num2); 
 return 0; 
} 
Run Code Online (Sandbox Code Playgroud)

输出将仅更改sizeof(void*)字符,而不是整个数组.

为什么会这样?

&num1是的char**,不是吗?

c string char

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

函数返回静态变量C++

我不明白为什么下面的程序错了:

 int& getID(){
   static int r = 0;
   return r++;
 }
Run Code Online (Sandbox Code Playgroud)

主要:

 int main(){
   int a = getID();
   std::cout << "a=" << a << std::endl;
   return 0;
 }
Run Code Online (Sandbox Code Playgroud)

为什么如上所述返回静态变量会产生问题而不返回所需的值?

c++ static

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

在字符串中查找最后一个char外观

如果有这个输入:

/Users/myMac/Desktop/MemoryAccess/BasicTest.asm/someStuff
Run Code Online (Sandbox Code Playgroud)

我想找到char "/"出现的最后一次 ,并得到字符串BasicTest

这样做的好方法是什么?

谢谢!

python string

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

python上的Makefile

我正在尝试为python脚本编写一个Makefile,它将创建一个 VMTranslator

可执行文件,应该获取输入,

这意味着它应该如何在shell命令上完成:

1)make <==== should make the VMTranslator executable.

2)VMTranslator BasicTest.vm <==== the user is supposed to use it like this.
Run Code Online (Sandbox Code Playgroud)

我根据在网上找到的内容尝试了以下内容:

#!/usr/local/bin/
    python *$
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

需要包含的文件是:codeWriter.py,vmTranslator.py,parser.py.

如何才能做到这一点?

python executable makefile

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

将"0"添加到二进制

如何在现有二进制类型的左侧添加"0"值?

我通过使用以下内容获取二进制类型:

 binary=bin(int(symbol))
Run Code Online (Sandbox Code Playgroud)

哪里symbol是int.

有没有办法做到这一点?

我希望结果是一个字符串.

python binary

-1
推荐指数
1
解决办法
1530
查看次数

在字符串中获取字符串c

我希望得到一个包含在字符串中的字符串,每次我看到(xxx) 我只能获得xxx.

我试图以递归方式使用函数来执行此操作int find(char* str).

1如果没有'('')'没有(全部删除),则该函数将返回,0否则返回.

字符串可以保持原样,只需要检查规定的条件.

确定输入: (xxx)(zzz(yyy)zzz)

不良输入: xx(x(zzz)(y

怎么能在C中完成?

c string recursion

-4
推荐指数
2
解决办法
160
查看次数