RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

E1mir's questions

Martin Hope
E1mir
Asked: 2022-10-02 01:17:29 +0000 UTC

如何实现从左到右滚动不与鼠标滚轮冲突

  • 0

网站上有一个元素,这个块应该在页面加载后自动水平滚动。

在此处输入图像描述

我做了它并写了以下内容:

scrolling = setInterval(() => {
  let scrolled = targetElement.scrollLeft;
  targetElement.scrollTo(targetElement.scrollLeft + 1, 0);
  // scrolled to the end, start again
  if (scrolled === targetElement.scrollLeft) {
      targetElement.scrollLeft = 0;
  }
}, 10);

但是这里出现了一个问题,当加载这段代码时,一切正常,但不幸的是,在使用这种方法时,使用鼠标滚轮滚动时会出现问题。当动画进行时,在chrome浏览器中是不可能用鼠标滚轮滚动的,但是在firefox中,这是不可能的。谁遇到了这个问题,也许你有其他方法可以解决这个问题。

PS:容器样式如下:

.providers {
  display: grid;
  overflow-x: scroll;
  grid-template-columns: max-content;
  grid-template-rows: 1fr 1fr;
  grid-auto-columns: 200px !important;
  grid-auto-flow: column;
  grid-gap: 20px;
  margin-top: 76px;
}
javascript
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-11-20 23:31:20 +0000 UTC

定位块从容器级别开始

  • 1

布置网站时,我无法对齐块..

我在容器中有一个不应超出其框架的块。但是该块较低,它从容器级别开始,但在设备屏幕本身的末尾结束,而不是容器本身。

如何计算该缩进以使块更低.another-block

.another-block {
  /*Я не знаю как тут вычислить отступ*/
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<section>
  <div class="container">
    <div class="row">
      <div class="col">
        <div class="block"> Элементы этого блока не должны выходить за рамки контейнера, как бы сильно я этого не хотел
        </div>
      </div>
    </div>
  </div>
  <div class="another-block">
    Начало данного элемента должна начинаться с уровня контейнера, но конец должен быть, аж до конца самого экрана устройства
  </div>
</section>

这里大概是下面的结果,我希望它和我在一起,但我不知道该怎么做。

在此处输入图像描述

html
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-09-01 01:55:06 +0000 UTC

Python 3 线程中的队列

  • 1

研究多线程,我写了一个小代码,理论上应该是依次启动线程,写了这么一个小脚本:

import queue
import threading

exit_flag = False


class MyThread(threading.Thread):

    def __init__(self, thread_id, name, q):
        threading.Thread.__init__(self)
        self.thread_id = thread_id
        self.name = name
        self.q = q

    def run(self):
        print("Starting {}".format(self.name))
        process_data(self.name, self.q)
        print("Exiting {}".format(self.name))


def process_data(working_thread, q):
    while not exit_flag:
        queue_lock.acquire()
        if not work_queue.empty():
            data = q.get()
            queue_lock.release()
            print("{} processing {}".format(working_thread, data))


thread_list = ["Thread-1", "Thread-2", "Thread-3"]
name_list = ["One", "Two", "Three", "Four", "Five"]

queue_lock = threading.Lock()
work_queue = queue.Queue(10)
threads = []
t_id = 1

for t_name in thread_list:
    thread = MyThread(t_id, t_name, work_queue)
    thread.start()
    threads.append(thread)
    t_id += 1

queue_lock.acquire()
for word in name_list:
    work_queue.put(word)
queue_lock.release()

while not work_queue.empty():
    pass

exit_flag = True

for t in threads:
    t.join()

print("Main thread end!")

最有趣的是,在调试模式下工作时,一切正常,但如果你只是让它运行,那么什么都不会发生,只有线程正在运行的消息。你能告诉我哪里出错了吗?

python
  • 3 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-02-02 19:51:50 +0000 UTC

如何在不改变纵横比的情况下调整图像大小?

  • 0

图像有以下 4x3 帧:

.image {
  width: 100%;
}

.image .image-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e7e7e7;
  padding: 2px;
  border-radius: 2px;
}

.image .image-wrapper.service {
  margin: 5px auto;
  height: 180px;
  width: 240px;
}

.image .image-wrapper img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}
<div class="image">
  <div class="image-wrapper service">
    <img src="//via.placeholder.com/100x200" />
  </div>
</div>
<div class="image">
  <div class="image-wrapper service">
    <img src="//via.placeholder.com/100x100" />
  </div>
</div>
<div class="image">
  <div class="image-wrapper service">
    <img src="//via.placeholder.com/200x100" />
  </div>
</div>

但是这里的情况是,如果图像较小,则居中,如果图像较大,则调整为比例。

如何在不改变纵横比的情况下使框架内的小图像增长并适合给定 4x3 框架的大小?

html
  • 2 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-11-09 17:25:44 +0000 UTC

如何计算组合元素的个数?

  • 0

再会!

我写了一行代码:

combined_elements = combinations(glob_elem, m)

我的任务是计算组合元素的数量......

我这样解决了这个问题:

comb_length = len(list(combined_elements))

但是有这样一个问题,如果我输入函数的数组里面的元素combinations()超过84,它就会给我MemoryError,程序就会停止工作……

但是,如果我注释掉或删除该行comb_length = len(list(combined_elements))并将长度为 1000 的数组传递给函数combinations(),它将无错地执行它。

然后我尝试了第二种方式:

def get_length(my_combined_list):
    length = 0
    try:
        while my_combined_list.next():
            length += 1
    except StopIteration:
        #ignored
    return length

第二个作品,但不幸的是很长一段时间......

您还能如何计算生成的元素组合的数量?

python
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-10-30 06:07:54 +0000 UTC

编译Dev-c++时出现Undefined reference错误

  • 0

下午好!我在编译的时候用C++写了一个简单的类,我遇到了这样一个奇怪的问题..我对C++不太了解,但这是我的.h和.cpp文件:

如果代码的拼写有错误,请留下这样的注释以备后用:C++不能这样写,但你要喜欢这样……

学生.cpp

#include "Student.h"
#include <string>
using std::string;

Student::Student(){}

void Student::setName(string n){
    name = n;
}
void Student::setSurname(string s){
    surname = s;
}
void Student::setAge(int a){
    age = a;
}
void Student::setCourse(int c) {
    course = c;
}
void Student::setGroup(string g){
    group = g;
}
void Student::setMarks(string* mark){
    marks = mark;
}
string Student::getName(){
    return name;
}
string Student::getSurname(){
    return surname;
}
int Student::getAge(){
    return age;
}
int Student::getCourse(){
    return course;
}
string Student::getGroup(){
    return group;
}
string* Student::getMarks(){
    return marks;
} 

学生.h

#ifndef Student_h
#define Student_h
#include <string>
using std::string;
class Student{

    public:
        Student();
        void setName(string);
        string getName();
        void setSurname(string);
        string getSurname();
        void setAge(int);
        int getAge();
        void setCourse(int);
        int getCourse();
        void setGroup(string);
        string getGroup();
        void setMarks(string*);
        string* getMarks();

    private:
        string name;
        string surname;
        int age;
        int course;
        string group;
        string* marks;
};
#endif

主.cpp

#include <stdio.h>
#include <iostream>
#include "Student.h"
using std::cout;
using std::endl;
int main(){
    Student test;
    string marks[] = {"B","B","C","A","A","A"};
    test.setName("Name");
    test.setSurname("Surname");
    test.setAge(100);
    test.setCourse(100);
    test.setGroup("606.4");
    test.setMarks(marks);

    cout << test.getName() << endl;
    cout << test.getSurname() << endl;
    cout << test.getAge() << endl;
    cout << test.getCourse() << endl;
    cout << test.getGroup() << endl;
    string* mark = test.getMarks();
    for(int i = 0 ; i < 6 ; i++){
        cout << mark[i] <<" ";
    }
}

我认为我做的一切都是对的,但是在编译过程中出现了一个奇怪的错误......

这是编译的时候Main.cpp

这是在编译 Main 方法时

这是编译时Student.cpp

编译学生

告诉我我所有的错误在哪里?

c++
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-10-23 07:23:01 +0000 UTC

读取 C++ 文件后输出不正确

  • 1

下午好!我有一个静态方法listOfStudents()可以打开一个文本文件并从那里读取我的数据......

我的文本文件如下所示:

文本文件

正如您在图片中看到的,一个带有数据的简单文本文件。

我的任务是从那里获取名字和姓氏并将其显示在屏幕上:

我的完整方法如下所示:

static void listStudents(){
    cout << endl << "List students" << endl<< endl;
    ifstream textfile;
    string line;
    string unused = "";
    textfile.open("students.txt");
    if(textfile.is_open()){
        int count = 0;
        for(int i = 0 , j = 0; !textfile.eof(); i++){
                if(i == j){
                    count++;
                    textfile >> line;
                    cout << count << ": " << line;
                    textfile >> line;
                    cout << " " << line << endl;
                    j+=11;
                }else{
                    textfile >> unused;
                    unused = "";
                }
        }
    }else{
        cout << "You don't have any students!" << endl;
    }
    textfile.close();
    cout << endl << endl;
    main();
}

我在一个文本文件中有 4 个学生,当我显示以下内容时:

问题

如您所见,一切都很好,只是在最后,出于某种原因,它生成了另外 1 行,其中前一个学生的姓氏重复了两次。


问: 他为什么要这样做?如何纠正?

c++
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-10-16 19:27:36 +0000 UTC

输入字符时无限循环

  • 0

下午好!在 C++ 上做实验室工作时,我遇到了以下问题:

我有一个readCommand读取命令的静态方法...并在成功输入后,将此命令传递给另一个方法choose(index)...

一切正常,但有这样一个问题,当输入数字时,一切正常,工作..但是如果你不小心输入的不是数字,而是符号或字母,方法中的循环将无限运行......

这是代码:

static void readCommand(){
    cout << endl <<"Select one: ";
    while(true){
        int index = 0;
        cin >> index;
        if(index < 1 || index > 4){
            cout << endl << "INDEX UNDEFINED!" << endl;
            cout << endl << "Select again: ";
        } else{
            choose(index);
            break;
        }
    }
}

该程序的工作原理如下:

程序示例

如何解决?作为 Java 鉴赏家,我知道您可以通过添加异常处理程序轻松避免这种情况。只有在 C++ 中我不知道该怎么做。

c++
  • 4 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-10-12 19:03:50 +0000 UTC

为什么数组没有排序?

  • 2

下午好!我正在用 C++ 训练排序算法,我遇到了以下问题:

我创建了一个由我通过键盘X给出的元素组成的数组。X这一切都在方法中完成main()

int length;
cout << "How many elements do you want to add? Type here: ";
cin >> length;
int array[length];

输入后,我用长随机数X填充我的数组。X并在屏幕上显示:

cout << "Your current array is:\n\n";
for(int i = 0; i < length; i++){
array[i] = rand() % 100;
printf("%d ", array[i]);
}

好吧,在那之后我们看到一个未排序的数组..

接下来,我创建一个方法,将我们的数组和我的元素作为参数,并使用 bubble 方法对其进行排序

void sort(int array[]){
    int length, temp, j;
    length = sizeof(array) / sizeof(*array);
    bool sort = true;
    while(sort){
        j++;
        sort = false;
        for(int i = 0 ; i < length - j; i++){
            if (array[i] > array[i+1]){
                temp = array[i];
                array[i] = array[i+1];
                array[i+1] = temp;
                sort = true;
            }
        }
    }
}

好吧,在main()我调用这个方法的方法中..

main(){
    //declare array
    sort(array);
    //output after sorting
}

但是当我运行程序时,我发现我的数组没有排序。我的错误在哪里?我知道,如果您用 Java 编写这样的实现,那么它就可以工作。但是正如我刚刚理解的那样,在 C++ 中则需要不同的方式。

c++
  • 2 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-10-04 04:03:05 +0000 UTC

使用 Java StringBuilder

  • 0

下午好


许多人都知道,Java使用这样的设计是不可取的。

"Hello" + "Name" + "Surname" + etc.;
//или же
String text = "Hello";
text += "Name";
text += "Surname";
text += etc...;

在这些情况下值得使用StringBuilder,虽然我对此有疑问,但我想知道我是否正确使用它?

public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("Name: " + this.getName());
    builder.append("\nSurname: " + this.getSurname());
    builder.append("\nAge: " + this.getAge());
    builder.append(this.isSex() ? "\nWoman " : "\nMan ");
    builder.append("\nCourse: " + this.course);
    builder.append("\nFaculty: " + this.faculty);
    builder.append("\nGroup: " + this.group);
    String result = new String(builder);
    return result;
}

查看代码,我认为我使用不正确......如果是这样,请告诉我它应该如何,以及在这种情况下使用什么是可取的?

java
  • 4 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-09-27 04:28:58 +0000 UTC

为什么无法识别语法和符号?

  • 0

昨天我做了一件事,之后我IntelliJ IDEA什么都认不出来了。

结果如下: 屏幕3

但是在项目结构中我已经设置好了所有内容,下面是截图: 屏幕1 屏幕2

一切都是默认的,但没有任何改变。我几乎到处搜索但没有找到答案。

但有趣的是,一切都可以编译并运行。

屏幕4

但是语法中的这些“错误”伤害了眼睛。

如何解决?

intellij-idea
  • 1 个回答
  • 10 Views
Martin Hope
E1mir
Asked: 2020-08-09 18:07:12 +0000 UTC

减少特定类别标签中的字符数

  • 1

使用该表时,我遇到了一个问题,该表中有以下数据:

  1. 元素编号
  2. 对象名称
  3. 对象类型
  4. 物体坐标

第4点,写物体坐标的地方,坐标太长了,我的任务是缩短这个长度:

这是表格本身:

<table>
  <tr>
    <th>ID</th>
    <th>Name</th>
    <th>Type</th>
    <th>Coordinates</th>
  </tr>
  <tr>
    <td>
      <b><i>16</i></b>
    </td>
    <td>
      TestPoint1
    </td>
    <td>
      Parking
    </td>
    <td>
      <span class="substring">40.381272280500674</span> : <span class="substring">49.842752143408234</span>
    </td>
  </tr>

  <tr>
    <td>
      <b><i>17</i></b>
    </td>
    <td>
      TestPoint2
    </td>
    <td>
      Bankomat
    </td>
    <td>
      <span class="substring">40.382694313910996</span> : <span class="substring">49.84732262756961</span>
    </td>
  </tr>

  <tr>
    <td>
      <b><i>18</i></b>
    </td>
    <td>
      TestPoint3
    </td>
    <td>
      Bank
    </td>
    <td>
      <span class="substring">40.379703105349265</span> : <span class="substring">49.84206549790042</span>
    </td>
  </tr>
</table>

如您所见,坐标很长,您需要缩短它们的长度。

我用 jQuery 写了一个脚本

$(".substring").substring(0,9);

这段代码不起作用,或者我做错了什么。请帮我解决问题。

javascript
  • 2 个回答
  • 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