小编six*_*eet的帖子

在Java语法中::的含义

以下代码中::的含义是什么?

Set<String> set = people.stream()
                        .map(Person::getName)
                        .collect(Collectors.toCollection(TreeSet::new));
Run Code Online (Sandbox Code Playgroud)

java syntax java-8

25
推荐指数
3
解决办法
2万
查看次数

使用C指针分配结构

任何人都可以解释以下代码的输出:

int main() {
    struct student {
        char *nume;
        char an[5];
    } a, b;

    a.nume = (char*)malloc(20);
    strcpy(a.nume, "Alex Popescu");
    strcpy(a.an, "1996");

    printf("%s %s\n", a.nume, a.an);

    b = a;
    strcpy(b.nume, "Emil Ionescu");
    strcpy(b.an, "1997");

    printf("%s %s\n", b.nume, b.an);

    struct student *pa = &a;

    printf("%s %s\n", pa->nume, (*pa).an);

    free(a.nume);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是:

 Alex Popescu 1996
 Emil Ionescu 1997
 Emil Ionescu 1996
Run Code Online (Sandbox Code Playgroud)

怎么b = a;办?被b指向相同的地址a?当你改变b.nameEmil Ionescu,也a正在改变它的价值?

为什么只有名称改变但是年份仍然存在1996

c pointers

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

使用 OpenCV 和 C++ 从图像中提取子图像

我正在尝试从 openCV 和 C++ 中的 RGB 图像获取子图像。我已经看过有关此主题的其他主题,但它对我不起作用。

这是我使用的代码:

Mat src = imread("Images/00011_00025.ppm");
Rect crop(1, 1, 64, 67);
Mat rez = src(crop);
Run Code Online (Sandbox Code Playgroud)

图像尺寸为 64x67,所以我不明白为什么在控制台中出现以下错误:

断言失败(0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.高度 <= m.rows)

关于这个错误的原因是什么的任何想法?

c++ opencv

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

使用OpenCV将灰度图像转换为负片

我正在尝试制作一个简单的函数,使用openCV将灰度图像转换为负像.下面我有函数的代码:

#include "stdafx.h"
#include "common.h"
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
.........................................

void negative_image()
{
    Mat img = imread("Images/cameraman.bmp", CV_LOAD_IMAGE_GRAYSCALE);

    for (int i = 0; i < img.row; i++)
    {
        for (int j = 0; j < img.cols; j++)
        {
            img.at<uchar>(i, j) = 255 - img.at<uchar>(i, j);
        }
    }

    imshow("negative image", img);
    waitKey(0);
}
Run Code Online (Sandbox Code Playgroud)

当我尝试构建应用程序时,我收到以下错误:

在此输入图像描述

任何帮助表示赞赏!

c++ opencv

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

C# LINQ 中 OrderBy(x =&gt; 1) 的含义

我遇到了一个 linq 表达式,如下所示:

var result = someCollection.Where(some_filter_condition).OrderBy(x => 1).ToList();
Run Code Online (Sandbox Code Playgroud)

我想知道OrderBy linq 方法中lambda 表达式x => 1的用途是什么?

c# linq lambda

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

预期的标识符或'('''''之前'

我为prim的算法编写了这段代码,我得到了这个错误:"期望的标识符'或''''int'之前的'.我有一个头文件,一个主文件和另一个.c文件.这是错误:"s algoritm 2\prim.h | 6 |错误:预期的标识符或'(''''''''''''''''''''''''''''''''

HEADER文件

#ifndef prim
#define prim
#define nmax 10

void prim(int mat[nmax][nmax],int x,int n ,int m);

#endif // graphs
Run Code Online (Sandbox Code Playgroud)

PRIM.c文件

#include <stdio.h>
#include <stdlib.h>
#include "prim.h"


void prim(int mat[nmax][nmax], int x, int n, int m)
{
int viz[nmax], u, v, min, total = 0;
int i, j, counter;

for(i = 0; i < n; i++)
{
    viz[i] = 0;
}

viz[x] = 1;

for(counter = 0; counter < m; counter++)
{
    min = 999;

    for(i …
Run Code Online (Sandbox Code Playgroud)

c

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

标签 统计

c ×2

c++ ×2

opencv ×2

c# ×1

java ×1

java-8 ×1

lambda ×1

linq ×1

pointers ×1

syntax ×1