小编X_T*_*ust的帖子

浮点异常(核心转储

程序:所以我制作了一个程序,它取两个数字,N和L. N是2D数组的大小,L是3到16的数字.程序构建数组并从中心开始并在其中运行逆时针螺旋.我是中心的值,当你通过数组(在螺旋中)时,值将增加1.这是质数,这一数字将被分配到那个地方,如果不是*将代替它来代替.

错误:我收到"浮点异常"错误,我该如何解决?

码:

 void Array_Loop( int *Array, int n, int L ) ;

int Is_Prime( int Number ) ;

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

  int **Array ;
  int n, L ;

  n = atoi( argv[1] ) ;
  L = atoi( argv[2] ) ;

  Matrix_Build( &Array, n, n ) ;
  Array_Loop( Array, n, L ) ;


  return 0 ;

}

void Array_Loop( int *Array, int n, int L ){

  int i, j, k, h ;
  int …
Run Code Online (Sandbox Code Playgroud)

c coredump

15
推荐指数
2
解决办法
11万
查看次数

为什么函数绑定到它们传递的第一个类型

我是F#的新手.我在乱搞,我发现了一些有趣的东西,我希望有人可以告诉我幕后发生的事情.

所以我做了这个功能:let my_func (x, y) = x + y.

然后我用args调用了函数12给了我3.这是我期望发生的事情,但是当我传递两个字符串时,my_func我得到了一个错误,即使它+是一个有字符串的有效运算符.我重新我的代码,但这次只调用my_func"cat"" dog"它给了我"cat dog".然后我试图通过12my_func才发现,my_func没有长期接受整数.

为什么my_func这样做?

let my_func (x, y) = x + y
my_func (1, 2) // produces => 3
my_func ("cat", " dog") // Error

重新运行程序 ......

let my_func (x, y) = x + y
my_func ("cat", " dog") // produces …

f#

5
推荐指数
1
解决办法
94
查看次数

Pytest:在 setup_method 中使用装置

遵循此模式:https : //docs.pytest.org/en/latest/xunit_setup.html

我如何使用/注射fixture_foo进入setup_method

class TestClassX:
    def setup_method(self, method):
        # I need `fixture_foo` here

    def teardown_method(self, method):
        # N/A

    def test_cool(self, fixture_foo):
        # Why can `fixture_foo` be injected here and not in `setup_method`?

Run Code Online (Sandbox Code Playgroud)

python pytest

5
推荐指数
1
解决办法
1174
查看次数

如何按列表中每个单词的第二个字母对列表/数组进行排序

我有一个名字数组,我需要根据每个名字的第二个字母对数组进行排序.

所以如果我有一个名单Names = [ "GWashington", "AJackson", "RNixon", "BObama" ]

我如何对它进行排序,以便按姓氏组织数组?

ruby sorting

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

标签 统计

c ×1

coredump ×1

f# ×1

pytest ×1

python ×1

ruby ×1

sorting ×1