RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-421207

kontsev_'s questions

Martin Hope
kontsev_
Asked: 2022-09-21 03:17:35 +0000 UTC

正确的正则表达式

  • 0

就 Unicode 正则表达式而言,表达式应该是什么样子:任何字符,不包括世界上任何字母表中的任何单词和任何数字?

任何字符,不包括世界上任何字母表中的任何单词,都表示为:

\\P{L}+

任何字符,不包括任何数字:

\\P{N}

但是如何从中获得一个考虑任何字符的正则表达式,除了数字或任何字母表中的任何单词

以下是 unicode 正则表达式站点 https://www.regular-expressions.info/unicode.html的链接

java
  • 0 个回答
  • 0 Views
Martin Hope
kontsev_
Asked: 2022-08-09 23:40:56 +0000 UTC

需要对错误进行解释

  • 0

执行程序时出现以下错误,它们是什么意思,我该如何解决?

[SUREFIRE] std/in stream corrupted
java.io.IOException: Command NOOP unexpectedly read Void data with length 4.
    at org.apache.maven.surefire.booter.MasterProcessCommand.decode(MasterProcessCommand.java:130)
    at org.apache.maven.surefire.booter.CommandReader$CommandRunnable.run(CommandReader.java:391)
    at java.base/java.lang.Thread.run(Thread.java:833)
System.exit() or native command error interrupted process checker.
java.lang.IllegalStateException: Cannot use PPID 10756 process information. Going to use NOOP events.
    at org.apache.maven.surefire.booter.PpidChecker.checkProcessInfo(PpidChecker.java:155)
    at org.apache.maven.surefire.booter.PpidChecker.isProcessAlive(PpidChecker.java:116)
    at org.apache.maven.surefire.booter.ForkedBooter$2.run(ForkedBooter.java:214)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
java
  • 1 个回答
  • 42 Views
Martin Hope
kontsev_
Asked: 2022-08-07 16:09:16 +0000 UTC

测试错误

  • 0

执行这段代码时:

final String testCases = MethodSourceParametrizedTesting.testCases()
                .map(arg -> Arrays.stream(arg.get()).map(Object::toString).collect(joining(",")))
                .collect(joining(";"));

出现以下错误:

java: cannot find symbol
  symbol:   method map((arg)->Arr[...]",")))
  location: interface java.lang.String[][]

测试本身:

class MethodSourceParametrizedTesting {

    Factorial factorial = new Factorial();

    public static String[][] testCases() {
        return new String[][]{
                {"1","1"}, {"2", "2"}, {"5", "120"}};
    }

    @ParameterizedTest
    @MethodSource("testCases")
    void testFactorial(String in, String expected) {
        assertEquals(expected, factorial.factorial(in));
    }

}
java java-stream
  • 1 个回答
  • 47 Views
Martin Hope
kontsev_
Asked: 2022-07-02 22:45:10 +0000 UTC

汉密尔顿循环的构造

  • 0

给定一个有向图,需要构造一个哈密顿圈。我不知道为什么程序不能正常工作。例如:

顶点 = 5
边 = 12
0 4
0 1
1 2
2 1
2 3
3 2
3 4
4 3
0 3
3 0
0 2
4 1
输出:0,1,2,3,4
预期结果:0,4,1, 2、3

n = int(input('Vertices: '))
m = int(input('Edges: '))
adj = [[0] * n for _ in range(n)]

for i in range(m):
    k, l = map(int, input().split())
    adj[k][l] = 1

used = [False] * n
path = []
def hamilton (v):
        path.append(v)
        if len(path) == n:
            if adj[path[0]][path[-1]] == 1:
                return True
            else:
                path.pop()
                return False
        used[v] = True
        for next in range(n):
            if adj[v][next] == 1 and not used[next]:
                if hamilton(next):
                    return True
        used[v] = False
        path.pop()
        return False

for i in range(n):
    hamilton(i)
    print (path)
    path.clear()
python
  • 2 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-06-29 10:58:51 +0000 UTC

DFS(深度图遍历)

  • 0

给出了一个没有多个边和环的无向图。该程序给出了这个错误:

File "dfsbfs.py", line 12, in dfs
    new_vertices = [j for j in adj[u] if j not in visited]
IndexError: list index out of range. 

我不明白为什么会这样。

n = int(input('Vertices: '))
m = int(input('Edges: '))
adj = []
for i in range(m):
    adj.append(list(map(int, input().split())))
def dfs(v):
    visited = {v}
    to_explore = [v]
    while to_explore:
        u = to_explore.pop()
        print (u)
        new_vertices = [j for j in adj[u] if j not in visited]
        to_explore.extend(new_vertices)
        visited.update(new_vertices)
dfs(0)
python
  • 1 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-04-24 00:55:31 +0000 UTC

切线法

  • 1

程序给出-nan,错误是什么?

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
double f(double x) {
    return (x * x - 2);
}
double f1(double x) {
    double h = 0.01;
    return ((f(x+h) - f(x-h))/2*h);
}
double f2(double x) {
    double h = 0.01, s;
    s = (f(x+h) - 2*f(x) + f(x-h))/h*h;
    return s;
}
double newton (double a, double b, double eps) {
    double xold, xnew, c;
    c = (a + b)/2;
        if(f1(c)*f2(c) > 0)
            xnew = a;
        else
            xnew = b;
        do {
            xold = xnew;
            xnew = xold - f(xold)/f1(xold);
        } while(fabs(xold - xnew) > eps);
        return xnew;
}
int main () {
    double a, b, eps;
    puts("eps a b");
    scanf ("%lf %lf %lf", &eps, &a, &b);
    printf ("%lf\n", newton(a, b, eps));
}
        
c
  • 1 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-04-23 19:13:03 +0000 UTC

三元搜索

  • 0

你能提出什么问题吗?[0;2]在具有精度的段上0.5,程序应该输出近似0.9,但在这种情况下它输出1.8。

#include <stdio.h>
#include <math.h>
double f(double x) {
    return (x*x*x - 3.0*x);
}
double ternar(double a, double b, double eps) {
    double l, r, mr, ml;
    r = b;
    l = a;
    while (fabs(r - l) > eps) {
        ml = l + (r - l)/3.0;
        mr = r - (r - l)/3.0;
        if(f(ml) < f(mr))
            l = ml;
        else 
            r = mr;
    }
        return (l+r)/2.0;
}
int main () {
    double a, b, eps;
    puts("a b eps");
    scanf ("%lf %lf %lf", &a, &b, &eps);
    printf ("Ternar: %lf\n", ternar(a, b, eps));
}
c
  • 1 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-02-28 12:55:02 +0000 UTC

使用 Jacobi 方法求解 SLE

  • 0

任务是使用 Jacobi 方法找到一个近似解,但是程序显示为零并且不继续迭代,我不明白如何修复此错误。

#include <stdio.h>
double diff(int n, double x1[n], double x2[n]) {
    double s = 0;
    int i;
        for( i = 0; i < n; i++) {
            s += (x2[i]-x1[i]) * (x2[i]-x1[i]);
        }
        return s;
}
double jacobi(int n, double x1[n], double x2[n]) {
    int i, j;
    double s = 0, a[n][n], f[n];
        for(i = 0; i < n; i++) {
            for(j = 0; j < i-1; j++) {
                s += x1[j]*a[i][j];
            }
            for(j = i+1; j < n; j++) {
                s += x1[j]*a[i][j];
            }
            x2[i] = (f[i] - s) / a[i][i];
        }
}
int main () {
    int n, i, j, k;
    double eps;
    printf ("Add N:\n");
    scanf ("%d", &n);
    printf ("Add epsilon:\n");
    scanf("%lf", &eps);
    double a[n][n], f[n], x1[n], x2[n];
        for(i = 0; i < n; i++) {
            for(j = 0; j < n; j++) {
                scanf("%lf", &a[i][j]);
            }
        }
        for(i = 0; i < n; i++) {
            scanf ("%lf", &f[i]);
        }
        for(i = 0; i < n; i++) {
            x2[i] = 0;
        }
        while(diff(n, x1, x2) > eps*eps) {
            for(i = 0; i < n; i++) {
                x1[i] = x2[i];
            }
            jacobi(n, x1, x2);
        }
        for(i = 0; i < n; i++)
            printf ("%lf", x2[i]);
}
    
c
  • 1 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-02-13 17:03:54 +0000 UTC

具有给定精度的系列的总和

  • 1

需要计算具有给定精度的序列:x - x^3/3 + x^5/5 - x^7/7 + ... 程序只计算序列到第一项,误差是多少,如何加速该计划?

#include <stdio.h>
#include <stdlib.h>
int factorial(int n) {
    if (n == 0)
        return 1;
    if (n > 0)
        return factorial(n - 1) * n;
}
long long deg(int n, double k) {
    if (n == 0)
        return 1;
    else
        return deg((n - 1), k) * k;
}
int main () {
    double eps;
    scanf ("%lf", &eps);
    double x, sum = 0.0, curr, prev;
    int k = 1, i = 0;
    scanf ("%lf", &x);
    curr =(deg(i,1) * deg(k,x)) / (double)k;
    prev = 0.0;
        while (abs(curr - prev) > eps) {
            if (i % 2 == 0)
                sum += curr;
            else
                sum -= curr;
            i++;
            k += 2;
            prev = curr;
            curr = (deg(i,1) * deg(k,x)) / (double)k;
        }
    printf ("%lf\n", sum); 
}
c
  • 1 个回答
  • 10 Views
Martin Hope
kontsev_
Asked: 2022-02-08 12:35:37 +0000 UTC

求分数之和

  • 1

给出了几个正分数,用空格隔开。计算分数之和(将结果减去最大公约数)

该程序给出了分段错误。错误在哪里?

    #include <stdio.h>             
        #include <stdlib.h>
            int gcd (int a, int b) {
                if (a == b) {
                    return a;
                else if (a > b) {
                    int tmp;
                    a = b;
                    b = tmp;
                }
            return gcd(a, b - a);
        }
        int main () {
            int a, b, sum = 0, pro = 1, n, *num = NULL, *den = NULL, j, tmp;
            scanf ("%d\n", &n);
            num = malloc(n * sizeof(int));
            den = malloc(n * sizeof(int));
                for (int i = 0; i < n; i++) {
                    scanf ("%d/%d\n", &num[i], &den[i]);
                }
                for (int i = 0; i < n; i++) {
                    pro *= den[i];
                    for ((j = 0 && j != i); j < n; j++)
                        tmp = num[i] * den[j];
                    sum += tmp;
                }
                if (gcd (sum, pro) != 1) {
                    sum %= gcd(sum, pro);
                    pro %= gcd(sum, pro);
                }
                printf ("%d/%d", sum, pro);
                free(num);
                free(den);
        }
c
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5