小编djv*_*jvu的帖子

提取numpy数组的边界

让我们A成为代表面具的numpy数组.我想提取对应于这个掩码的边界,即除边界外,使一切都为零.

例如:

In [22]: A
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, …
Run Code Online (Sandbox Code Playgroud)

numpy mask

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

为什么我不能将值赋值分成两个不同的语句?

   #inlude <stdio.h>
   typedef struct node
   {
     int data, height, count;
     struct node *left, *right, *father;
   }node;
   node *root = NULL;
   void main(){
   //some code here
   }
Run Code Online (Sandbox Code Playgroud)

上面的代码没有错误,但是

  #inlude <stdio.h>
   typedef struct node
   {
     int data, height, count;
     struct node *left, *right, *father;
   }node;
   node *root;
   root = NULL;
   void main(){
   //some code here
   }
Run Code Online (Sandbox Code Playgroud)

这会产生以下错误:

sample.c:11:1: error: conflicting types for 'root' 
sample.c: 10:7 note: previous declaration of 'root' was here 
node *root; 
      ^
Run Code Online (Sandbox Code Playgroud)

声明时不再复制上述错误

root = NULL;
Run Code Online (Sandbox Code Playgroud)

在...内宣布 main function …

c null pointers initialization variable-assignment

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

标签 统计

c ×1

initialization ×1

mask ×1

null ×1

numpy ×1

pointers ×1

variable-assignment ×1