RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Ildar's questions

Martin Hope
Ildar
Asked: 2022-08-10 05:33:27 +0000 UTC

如何在 C、Linux 中擦除打印到控制台的最后一行

  • -1

"press any key"分页需要将数据部分输出到控制台,按任意键后需要擦除,我尝试了不同的特殊字符和回车,没有任何帮助,请高手帮忙。你需要在 gdb 分页中使用----more----.

#include <conio.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
    while (true) {
        /* какие то полезные данные */
        printf("********\n");
        printf("********\n");
        printf("********\n");
        /* какие то полезные данные */

        printf("press any key\n");
        const int c = getch();
        if (c == 'q') {
            break;
        }
    }

    return 0;
}
linux c++
  • 1 个回答
  • 78 Views
Martin Hope
Ildar
Asked: 2022-08-02 17:38:14 +0000 UTC

是否可以从 AVL 树中删除,仅使删除的元素失效

  • 0

我把迭代器存储在AVL树的元素上,当一个元素从中移除时,一些迭代器可能会指向其他元素,也就是说,它们会失效。是否可以仅在已删除元素失效的情况下从树中删除?如果可能,请分享想法,实现。在 Internet 上找到的所有实现都会在删除期间从一个节点复制到另一个节点。在 STL 红黑树中,只有被移除的元素被标准无效化。

алгоритм c++
  • 1 个回答
  • 28 Views
Martin Hope
Ildar
Asked: 2022-05-06 19:15:15 +0000 UTC

SELECT...WHERE 查询问题

  • 1

有一个计划

create table "Messenger".public.group
(
    id       serial primary key,
    name     varchar(32) unique not null,
    password varchar(128)       not null
);

填充以下值

6,main,1234
7,new life,1234
8,lions,1234

当我用这段代码在 Qt 中请求数据时,我得到了所有的密码

QSqlQuery query(conn);
query.exec("select * from \"Messenger\".public.group");
while (query.next()) {
   qDebug() << query.value("password").toString();
}

但是当我想获取某个组的密码时,查询什么也不返回

QSqlQuery query(conn);
query.exec("select * from \"Messenger\".public.group where name = 'main'");
while (query.next()) {
    qDebug() << query.value("password").toString();
}

谁知道如何解决请求where?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2022-07-05 15:33:32 +0000 UTC

如何在 Qt Creator 上添加美化器以自动格式化代码

  • 1

我想在 上安装一个用于自动格式化代码的插件C++,但我找不到下载位置以及如何source立即beautifier安装clang format它

在此处输入图像描述

如果有人知道如何做到这一点,我将非常乐意提供帮助!

c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2022-06-22 00:47:51 +0000 UTC

这样的指令在 C++ 中意味着什么?

  • 0
int main()
{
  int a[10] = { [0 ... 5] = 1,[6 ... 9] = 2 };

  return 0;
}

0在MacOS, 编译器LLVM Clang, IDE上编译并返回代码Xcode

c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2022-04-17 20:27:57 +0000 UTC

如何从没有分隔符的字符串中获取日期?

  • 2

有一个这种格式的字符串20140102125832。

DATE从这个字符串中获取类型的最惯用的好方法是什么?

输入:20140102125832

结论:2014-01-02 12:58:32

sql
  • 2 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2022-02-24 05:04:46 +0000 UTC

selenium 没有从页面中提供 html 部分

  • 0

我从下面一个机构的网站收集信息url,我想获取员工及其姓名的链接,driver加载此信息,它在浏览器中可见,但html取的是哪一个,即page_source没有这个信息,可能是什么问题?

from selenium import webdriver
from bs4 import BeautifulSoup

url = 'https://kpfu.ru/computing-technology/struktura/kafedry/kafedra-prikladnoj-matematiki/kafedra-prikladnoj-matematiki-sotrudniki'

driver = webdriver.Firefox(executable_path=constants.gecko_path)
driver.get(url)
html = driver.page_source

def gather_employees_links(html):
    soup = BeautifulSoup(html, 'lxml')

    spans = soup.find_all('span', class_='fio')
    a_tags = [span.find('a') for span in spans]
    employees = {a.text: a.get('href') for a in a_tags}

    return employees

print(gather_employees_links(html))
python
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2022-01-04 19:58:07 +0000 UTC

如何为基本类型定义一种模板特化,为自定义类型定义另一种模板特化

  • 1

我需要该函数在将基本类型传递给它时执行一个代码,而在传递自定义类型时,行为是不同的。我读过std::is_fundamental它,但它已经在代码中被调用,如果我做这样的检查,我的函数将不会编译,因为模板函数包含对简单类型没有的方法的调用,如何在实例化过程中直接确定?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2021-12-24 03:52:33 +0000 UTC

什么比较方法足以在python中重载,以便您可以对自己类的对象进行排序

  • 0

我有一个自定义类,它需要按特定属性排序(您可以从属性中抽象出来),我需要重载哪些比较方法才能使排序正常工作?因为在我看来,所有方法都被冗余地重载了

python
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-09-09 20:09:05 +0000 UTC

离散经验分布函数 (cdf) 的构造

  • 2

构造离散分布函数时如何去除垂直线?

我目前的日程安排是什么: 在此处输入图像描述

import matplotlib.pyplot as plt


def plot_empirical_cdf(sample):
    plt.hist(sample, histtype='step', cumulative=True, bins=len(sample))
    plt.show()


sample = [123.0, 119.5, 120.5, 118.1, 117.5, 118.2, 124.5, 115.9, 121.0, 126.0, 121.3, 121.0, 118.2, 120.2, 124.3, 118.5, 117.2, 125.5, 115.0, 119.5, 126.0, 120.0, 126.5, 121.0, 125.0, 123.0, 122.7, 120.5, 122.5, 122.0, 122.5, 122.5, 122.5, 117.2, 123.0, 128.5, 120.5, 118.9, 116.2, 125.0, 125.1, 121.8, 122.0, 120.5, 123.0, 115.0, 120.5, 118.0, 125.0, 115.0, 117.0, 125.9, 122.0, 120.5, 121.1, 123.5, 120.7, 125.8, 120.5, 119.0, 120.5, 120.2, 123.0, 120.0, 117.2, 122.6, 120.2, 120.5, 123.0, 121.5, 120.0, 119.5, 115.0, 122.9, 123.3, 121.0, 122.5, 119.0, 124.0, 120.5, 121.9, 124.2, 121.5, 118.2, 122.2, 121.5, 120.0, 123.0, 119.5, 117.8, 119.2, 116.0, 123.0]
plot_empirical_cdf(sample)
python
  • 2 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-08-16 22:22:10 +0000 UTC

为什么条件变量需要互斥锁

  • 4
  1. 为什么unique_lock在调用wait条件变量的方法之前锁定互斥锁?
  2. 为什么该方法wait需要互斥锁作为参数,因为如果我愿意,我会在醒来后自己阻塞必要的互斥锁?
  3. notify_one在另一个线程中调用条件变量之前是否有必要锁定同一个互斥锁?

一些背景

#include <iostream>

#include <thread>
#include <mutex>
#include <condition_variable>

std::mutex outputStreamMutex;

std::mutex productMutex;
std::condition_variable condVar;
bool productReady = false;

class Product 
{
public:
  void make() {}
} product;


void makeProduct()
{
  {
    std::lock_guard<std::mutex> lock(outputStreamMutex);
    std::cout << "making process...\n";
  }

  {
    std::lock_guard lock(productMutex);
    product.make();
    productReady = true;
    condVar.notify_one();

    std::lock_guard<std::mutex> lockStream(outputStreamMutex);
    std::cout << "product is made\n";
  }
}

void send(const Product& prod)
{
  //...
}

void sendProduct()
{
  {
    std::lock_guard<std::mutex> lock(outputStreamMutex);
    std::cout << "waiting product process...\n";
  }

  {
    std::unique_lock lock(productMutex);
    condVar.wait(lock, []() {return productReady;});
    send(product);
    productReady = false;

    std::lock_guard<std::mutex> lockStream(outputStreamMutex);
    std::cout << "product is sent\n";
  }
}


int main()
{
  std::thread makerThread(makeProduct);
  std::thread senderThread(sendProduct);
  makerThread.join();
  senderThread.join();

  return 0;
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-08-14 23:36:17 +0000 UTC

受互斥体保护的缓冲区ostream?

  • 3

有这样一段人为的代码,输出流故意不受互斥锁保护

#include <iostream>
#include <string_view>
#include <thread>

void print(std::string_view message)
{
  for (int i = 0;i < 10000;++i) {
    std::cout << message;
  }
}

int main()
{
  std::thread t1(print, "hello\n");
  std::thread t2(print, "aloha\n");
  t1.join();
  t2.join();

  return 0;
}

输出是某种随机的

...
hello
hello
aloha
hello
aloha
...

但是为什么字是作为一个整体输出的,没有和这样的字符混淆,这haelohallo是否意味着输出流缓冲区受到互斥锁的保护,不允许多个线程写入,或者是安排在其他一些棘手的方式?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-07-22 04:50:12 +0000 UTC

如何将第三方python模块拉入exe

  • 1

exe使用它将您自己编写的模块组装成一个模块pyinstaller,但是是否有可能以某种方式将第三方模块拉入exe而不是将它们拖到可执行文件旁边的虚拟环境中?

python
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-07-18 14:17:37 +0000 UTC

标准 python 容器使用什么数据结构

  • 2

我在哪里可以找到代表哪些数据结构容器:字符串、列表、元组、集合、字典,或者 Python 标准对这些容器的承诺是什么?

如果脚本处理大量数据并且知道哪些操作是昂贵的,哪些不是非常有用,我认为这非常重要。

python
  • 2 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-07-13 04:39:23 +0000 UTC

来自临时对象的 this 指针

  • 0

例如有这样一个人为的类

class Example
{
public:
  int x = 0;
  Example& get_ref()
  {
    return *this;
  }
};

这样的一行自然会导致错误,因为我们对右值进行了非常量引用

Example& example = Example();

但是为什么这个例子不会导致错误,如果它是相同的,我们甚至可以通过这个链接改变状态?(或者不一样?)

Example& example = Example().get_ref();

指针如何this获取临时对象的地址?我在引擎盖下想象它是这样的Example* this = &(объект вызывающий метод),并没有真正考虑过,因为我从来没有从右值调用方法,也没有调用过并且没有考虑过......

c++
  • 2 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-04-13 20:59:26 +0000 UTC

二部图中的最大匹配

  • 0

除了 Kuhn 和 Hopcroft-Karp 算法,还有什么算法可以解决这个问题(二部图中的最大匹配)?

алгоритм
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-04-13 03:19:54 +0000 UTC

随机范围变化

  • 1

在构造函数中设置后如何设置新的分布范围,还是我仍然需要创建一个新变量?

#include <random>
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(1,6);
c++
  • 1 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-01-10 22:51:36 +0000 UTC

模板类中的语法

  • 3

我们只有一个模板,Vector<T>即 编译器允许这样的语法并没有什么特别的原因,以及是否需要像Vector下面这样编写或者是否需要Vector<T>为参数和返回值编写

提出问题的行包含评论

template <class T>
class Vector {
protected:
  int length;
  T *mas;
public:
  Vector(int n);
  Vector(const Vector &z); // здесь в параметре не Vector<T>
  Vector(int n, T*a);
  Vector() {};
  ~Vector();
  int Length()const { return length; }
  T& operator[](int i);
  Vector& operator=(const Vector &right); // здесь в возвращаемом значении и параметре не Vector<T>
};

也在方法定义中

template <class T>
Vector<T>& Vector<T>::operator=(const Vector &right) {  // здесь в параметре не Vector<T>
  if(&right == this)
    return *this;
  if (right.length != length) {
    delete[] mas;
    length = right.length;
    mas = new T[length];
  }
  for (int i = 0; i < length; ++i)
    mas[i] = right.mas[i];
  return *this;
}
c++
  • 2 个回答
  • 10 Views
Martin Hope
Ildar
Asked: 2020-11-10 00:15:04 +0000 UTC

更改 windows 10 界面语言

  • 0

我无法更改界面语言 oc,也许有人知道如何在不重新安装 Windows 的情况下解决此问题,正如您在屏幕截图中看到的那样,没有设置默认语言或作为界面语言的按钮

在此处输入图像描述

在此处输入图像描述

windows-10
  • 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