RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

dbUser11's questions

Martin Hope
dbUser11
Asked: 2022-06-23 04:16:45 +0000 UTC

数字输入错误时如何组织错误输出?

  • 1

我有输入。

输入中必须输入整数。

我的任务是在布局中显示我现在放在控制台上的错误(calculate.js函数)

从理论上讲,我知道该怎么做,但我无能为力。我需要创建一个有错误的元素,以防输入无效,例如输入上方的文本,然后当输入正确时,我需要删除此错误消息。

问:怎么办?

链接到项目。

javascript
  • 1 个回答
  • 26 Views
Martin Hope
dbUser11
Asked: 2022-06-21 04:44:05 +0000 UTC

如何为表格制作滚动条?[关闭]

  • 0
关闭 这个问题是题外话。目前不接受回复。

寻求调试帮助的问题(“为什么这段代码不起作用? ”)应该包括期望的行为、具体的问题或错误,以及在问题中重现它的最少代码。没有明确描述问题的问题对其他访问者毫无用处。请参阅如何创建一个最小的、独立的和可重现的示例。

5 个月前关闭。

改进问题

我有一个项目。一页纸。

页面上生成的表格在小屏幕上爬出屏幕。我想解决这个问题。如何使表格滚动?我尝试使用overflow: scroll;for .main-table,但它对我不起作用......

链接到样式。

css
  • 1 个回答
  • 25 Views
Martin Hope
dbUser11
Asked: 2022-06-17 06:09:14 +0000 UTC

如何使弹性表单自适应?

  • 0

我正在尝试为弹性注册表单进行自适应设计。

我得到了一个有趣的stackoverflow的想法和其他一些东西,但我从来没有走到那一步。

问题的本质归结为我需要制作这样的布局: 在此处输入图像描述

我做了点什么。但我有一些问题。

  1. 我无法在 First name 和 Last name 字段之间设置填充(这很可能是因为我有flex: 1)。margin || padding出于同样的原因,我无法在帮助下设置缩进。
  2. 我无法使伪元素自适应(窄屏幕上“Register”一词附近的行覆盖文本)。

你能帮我提供一个真实的代码示例吗?我该如何解决这两个问题?我什么都不懂...

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}

body {
    background: #F2F3F7;
}

a {
    text-decoration: none;
    color: green;
}

.wrapper-form {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.main-label {
    font-weight: bold;
    font-size: 40px;
    margin-bottom: 16px;
}

.main-text {
    font-size: 20.5px;
    margin: 22px 22px;
}

.register-form {
    display: flex;
    flex-direction: column;

    min-width: 40%;
}

.main-top {
    margin-top: 20px;
}

.main-input-container {
    display: inherit;
    flex-wrap: wrap;
}

.main-input {
    flex: 1;
    height: 65%;
    border-radius: 5px;
    padding: 15px;
    border-color: gainsboro;
}

.register-button {
    padding: 10px;
    font-weight: bold;
    font-size: 18px;
    border-radius: 5px;
    background: #55AD56;
    color: white;
    border-color: #55AD56;
}

.main-label-container {
    text-align: center;  
    width: 80%;          
    margin: 0 auto;      
    overflow: hidden;    
}

.main-label {
    position: relative;
}

.main-label::before {
    content: '';                     
    display: block;                  
    min-width: 17.5%;                   
    position: absolute;              
    border-bottom: 2px solid #D0D1D5;   
    top:50%;                         
    right: 24%;                    
}

.main-label::after {
    content: '';
    display: block;
    min-width: 17.5%;
    position: absolute;
    border-bottom: 2px solid #D0D1D5;
    top:50%;
    left: 24%;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/css/reset.css">
    <link rel="stylesheet" href="./assets/css/style.css">
    <title>Registration form</title>
</head>
<body>
    <main>
        <section class="wrapper-form">
            <div class="main-label-container">
                <h1 class="main-label">Register</h1>
            </div>
            <p class="main-text">Create your account. It's free and only takes a minute.</p>

            <form action="#" method="get" class="register-form">
                <section class="main-input-container">
                    <input type="text" name="name" class="main-input main-top" placeholder="First Name" required>
                    <input type="text" name="surname" class="main-input main-top" placeholder="Last Name" required>
                </section>
                <input type="email" name="email" class="main-input main-top" placeholder="Email" required>
                <input type="password" name="password" class="main-input main-top" placeholder="Password" required>
                <input type="password" class="main-input main-top" placeholder="Confirm Password" required>
                <label>
                    <input type="checkbox" name="accept" class="main-top" value="trueAccept">
                    I accept the <a href="#">Terms of Use</a> & <a href="#">Privacy Policy</a>.
                </label>
                <button type="submit" class="register-button main-top">Register Now</button>
            </form>
        </section>
    </main>
</body>
</html>

css
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-06-13 22:03:58 +0000 UTC

屏幕缩小时如何将flex子元素放在前面?

  • 0

我正在制作导航栏。

在大屏幕上,一切看起来都如我所愿。

小屏问题。

当屏幕缩小时,flex 子元素应该对齐到左边缘。但这不会发生。他们居中。

这是我屏幕上的样子:

在此处输入图像描述

我希望它看起来像这样:

在此处输入图像描述

您不能使用媒体查询或类似的东西。问题的条件:只有弯曲,没有别的。

那么如何才能得到和图片一样的效果呢?

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.footer {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;

    background: black;
    font-weight: bold;
    padding: 8px 8px;
}

.footer-name {
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
}

.footer-nav-item {
    padding-left: 10px;
}

.footer-nav-item {
    text-decoration: none;
}

.footer-button {
    font-size: 8px;
    background: inherit;
    border: 1px solid white;
    padding: 4px 4px;
}

.white {
    color: white;
}

.footer-margin {
    margin: 8px 8px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/css/reset.css">
    <link rel="stylesheet" href="./assets/css/styles.css">
    <title>Flex navigation</title>
</head>
<body>
    <footer class="footer">
        <p class="footer-name footer-margin white">Rio Coffee</p>

        <nav class="footer-nav footer-margin">
            <a class="footer-nav-item white" href="#">HOME</a>
            <a class="footer-nav-item white" href="#">ABOUT</a>
            <a class="footer-nav-item white" href="#">SERVICES</a>
            <a class="footer-nav-item white" href="#">MENU</a>
        </nav>
        
        <button class="footer-button footer-margin white">CONTACT</button>
    </footer>
</body>
</html>

css
  • 2 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-06-11 22:40:51 +0000 UTC

如何在导航栏中正确定位菜单?

  • 1

我有一个导航栏。

导航栏具有多级下拉列表。一切似乎都很好,但是在设置了 5 个像素的边框后,我意识到我的定位有误……因为我没有得到预期的结果。

这是导航栏在我的屏幕上的显示方式: 我屏幕上的导航栏视图

列表显示不均匀已经很明显了。

第三级的列表一般会在错误的地方打开...

为了让它看起来像我需要的那样,我用了一个拐杖:

/* Меню третьего уровня (модификатор, который открывает меню вправо) */
.sub-nav-list-right {
  left: 100%;
  top: -1px;
}

这是没有这个拐杖的打开方式(我相信女人): 当悬停在 wooman 上时

这个问题可以解决:设置正确的填充,它应该是,但我想弄清楚定位......我定位错了什么?

导航栏的各个部分应如何打开: 我想要的是

代码如下。

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.nav-list {
  font-size: 0;
  margin: 15px 30px;
}

.nav-list-item {
  position: relative;
  font-size: 18px;
  display: inline-block;
  border: 10px solid #367452; /* 0.1 */
  background-color: #47986d;
  
  /* !!!!! */
  width: 150px;
  text-align: center;
  color: white;
  text-transform: capitalize;
}

.link {
  display: block;
  padding: 10px 20px;
  text-decoration: none;
  color: inherit;
}

.sub-nav-list {
  position: absolute;
  display: none;
  left: 0;
  right: 0;
}

/* Меню третьего уровня (модификатор, который открывает меню вправо) */
.sub-nav-list-right {
  left: 100%;
  top: -1px;
}

.sub-nav-item {
  display: block;
}

.nav-list-item:hover > .sub-nav-list {
  display: block;
}

.nav-list-item:hover {
  background-color: #3c805b;
}

.main-article {
  margin: 30px;
  font-size: 18px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Главная страница</title>
    <link rel="stylesheet" href="./assets/css/reset.css" />
    <link rel="stylesheet" href="./assets/css/style.css" />
  </head>
  <body>

    <header>
      <nav>

        <ul class="nav-list">
          <li class="nav-list-item">
            <a href="https://youtube.com" target="_blank" class="link">Home</a>
          </li>
          <li class="nav-list-item">
            <a href="#" class="link">Categories</a>
            
            <!-- Drop-down list -->
            <ul class="sub-nav-list">
              <li class="sub-nav-item nav-list-item">
                <a href="#" class="link">Man</a>
              </li>
              <li class="sub-nav-item nav-list-item">
                <a href="#" class="link">Woman</a>
                
                <!-- Drop-down list -->
                <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
                <ul class="sub-nav-list sub-nav-list-right">
                  <li class="sub-nav-item nav-list-item">
                    <a href="#" class="link">Dress</a>
                  </li>
                  <li class="sub-nav-item nav-list-item">
                    <a href="#" class="link">Pants</a>
                  </li>
                  <li class="sub-nav-item nav-list-item">
                    <a href="#" class="link">Shoes</a>
                  </li>
                </ul>
                <!-- END drop-down list -->

              </li>
              <li class="sub-nav-item nav-list-item">
                <a href="#" class="link">kids</a>
              </li>
            </ul>
            <!-- END drop-down list -->

          </li>
          <li class="nav-list-item">
            <a href="#" class="link">About</a>
          </li>
          <li class="nav-list-item">
            <a href="#" class="link">Contacts</a>
          </li>
        </ul>

      </nav>
    </header>
    
    <main>

      <article class="main-article">
        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Reiciendis
        aliquam rerum sapiente quas, veniam hic illum qui assumenda numquam magni
        aliquid vitae, asperiores eius nesciunt expedita vero error ducimus enim
        dignissimos ut voluptas esse molestiae ipsum dolores. In delectus ipsa
        possimus. Sequi, tenetur corrupti! Iusto minus cum illum impedit fugiat
        tenetur cupiditate iste veniam natus, aliquid dignissimos consequatur
        magnam voluptate rem enim quisquam nostrum sed! Esse delectus distinctio a
        aliquid libero rem assumenda, error eaque magnam quidem dolorum impedit
        laudantium cupiditate quam! Necessitatibus quibusdam ipsa aspernatur rem
        excepturi delectus voluptatem, quis nihil voluptate harum architecto
        repellat dolorum vero corrupti quam officia similique, sequi sint veniam
        dicta natus amet consequuntur a incidunt? Id ipsam libero minus,
        architecto dolorum harum officiis explicabo ad iure ipsa, possimus
        repellat nisi! Inventore molestiae est magni dolor ut nam sequi quibusdam
        aperiam maiores corporis doloremque beatae ducimus, nihil quam consectetur
        asperiores laudantium maxime vero sit expedita? Architecto eveniet,
        suscipit totam nesciunt tempora voluptatem atque quibusdam vitae est.
        Incidunt quia alias veritatis unde vero vel beatae recusandae ipsum
        aperiam adipisci at officia rerum totam maxime quas et, pariatur aut
        voluptatum, asperiores sit eveniet. Omnis accusamus ad repellendus
        possimus id praesentium sapiente nisi aut exercitationem sequi blanditiis
        itaque repudiandae quidem, ratione quasi dicta in velit ut necessitatibus
        rerum. Corporis aut ut voluptas, doloremque eveniet, repellendus delectus
        iure perspiciatis ratione quos officia illo minus quae expedita quasi
        veritatis quo culpa harum deserunt doloribus fugit dolorem! Repellendus
        sapiente facilis beatae magnam nisi quod voluptate, commodi officia
        recusandae doloremque deserunt provident dicta. Dolores quibusdam magnam
        enim aliquid amet nesciunt, sequi consectetur nihil, ullam aliquam eum?
        Deserunt ipsum necessitatibus cupiditate iure unde similique vero pariatur
        error illo enim dolorem voluptates, expedita, officia facilis quasi
        voluptatibus incidunt. Blanditiis, hic? Possimus exercitationem blanditiis
        fugiat quaerat labore quam consequatur, dolorem ex asperiores odit
        obcaecati maiores laudantium soluta nisi neque alias beatae consectetur
        officia excepturi dignissimos ratione ea assumenda? Fugit minima corporis
        alias tempore reiciendis quas earum, aut necessitatibus voluptatem ipsam
        debitis nemo labore officiis numquam repudiandae recusandae similique,
        totam ipsum maiores perferendis libero. Error vel officia autem vero nihil
        perferendis maiores, laborum maxime quam ab perspiciatis in, ratione
        soluta qui magni quibusdam cumque sed nisi velit rerum ut facilis,
        assumenda odio dolor? Repellat, voluptate non beatae hic expedita amet
        voluptates magni. Placeat nobis laboriosam quas quibusdam odio voluptate
        doloribus doloremque labore repudiandae nulla amet, ipsum eum maxime
        corrupti. Saepe porro nostrum molestiae id alias! Incidunt?
      </article>

    </main>
  </body>
</html>

css
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-06-09 20:16:18 +0000 UTC

如何将 div 转换为伪元素?

  • 0

落实了任务。

我有三张卡片,卡片上有两个圆圈。这两个圈子纯粹是视觉上的,与内容无关。圆圈是使用两个<div>.

我设定了任务:<div>从 index.html 中的每张卡片中删除这 2 个,并实现相同的圆圈,但通过伪元素......

问:怎么办?我不明白要绑定到哪个选择器......尝试了很多东西,但圆圈消失了......

* {
    box-sizing: border-box;
    padding: 0;
    margin: 15px;
    font-family: 'Courier New', Courier, monospace;
}

.icons {
    position: absolute;
    margin-left: 320px;
}

.main-block {
    display: inline-block;
    position: relative;
    width: 30%;
    padding: 3%;
    font-weight: 900;
    color: white;
    border-radius: 10px;

    overflow: hidden;

    margin-left: 28px;
}

/* Margin-top section */
.mt-medium {
    margin-top: 10px;
}

.mt-larger {
    margin-top: 25px;
}
/* End margin-top section */

/* Block colors section */
.color-first-block {
    background: linear-gradient(90deg, rgba(254,190,154,1) 0%, rgba(255,130,152,1) 100%);
}
.color-second-block {
    background: linear-gradient(90deg, rgba(133,196,243,1) 0%, rgba(27,145,228,1) 100%);
}
.color-third-block {
    background: linear-gradient(90deg, rgba(116,218,208,1) 0%, rgba(5,209,186,1) 100%);
}
/* End block colors section */

/* Circles-sections */
.upper-circle {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    position: absolute;
    left: 260px;
    top: -180px;
    background: rgba(255, 255, 255, 0.3);
}

.bottom-circle {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    position: absolute;
    left: 220px;
    top: 85px;
    background: rgba(255, 255, 255, 0.3);

    overflow: hidden;
}
/* End circles sections */
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/styles/reset.css">
    <link rel="stylesheet" href="./assets/styles/styles.css">
    <title>Position medium</title>
</head>
<body>
    <main>
        <!-- First block -->
        <div class="main-block color-first-block">
            <img class="icons" src="./assets/img/chart-line.svg" alt="chart-line">
            <p>Weekly sales</p>
            <p class="mt-medium">$ 15.0000</p>
            <p class="mt-larger">Increased by 60%</p>

            <!-- circles section -->
            <div class="upper-circle"></div>
            <div class="bottom-circle"></div>
            <!-- end circles section -->
        </div>
        <!-- End first block -->

        <!-- Second block -->
        <div class="main-block color-second-block">
            <img class="icons" src="./assets/img/bookmark-outline.svg" alt="bookmark-outline">
            <p>Weekly orders</p>
            <p class="mt-medium">45,6334</p>
            <p class="mt-larger">Decreased by 10%</p>

            <!-- circles section -->
            <div class="upper-circle"></div>
            <div class="bottom-circle"></div>
            <!-- end circles section -->
        </div>
        <!-- End second block -->

        <!-- Third block -->
        <div class="main-block color-third-block">
            <img class="icons" src="./assets/img/diamond.svg" alt="diamond">
            <p>Visitors online</p>
            <p class="mt-medium">95,5741</p>
            <p class="mt-larger">Increased by 5%</p>

            <!-- circles section -->
            <div class="upper-circle"></div>
            <div class="bottom-circle"></div>
            <!-- end circles section -->
        </div>
        <!-- End third block -->
    </main>
</body>
</html>

它在我的屏幕上的外观(stackoverflow 上的代码以某种方式奇怪地执行):

在我看来如何

html
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-06-07 01:43:19 +0000 UTC

如何显示圆圈的相邻部分?

  • 0

我正在实施一个块。块内应该有2个圆圈。在这种情况下,圆圈中一定有一些相邻的部分。

理想情况下,它应该看起来像这样: 我需要做什么

我能够添加 2 个圆圈(.upper-circle& .bottom-circle)。.inner-circle我以另一个附加的第三个圆圈 ( )的形式实现相邻区域。

第三圈已经投资于底部。

似乎有些东西有效,但没有任何效果。不知道你的想法对不对?也许它可以以某种方式更容易完成..?我什么都不懂。我不明白如何显示圆圈的相邻部分,通常,而不是我现在拥有的方式以及如何隐藏超出框架边界的圆圈部分......

* {
    box-sizing: border-box;
    padding: 0;
    margin: 1%;
    font-family: 'Courier New', Courier, monospace;
}

.main-block {
    display: inline-block;
    width: 30%;
    padding: 3%;
    font-weight: 900;
    color: white;
    border-radius: 10px;
}

/* Margin-top section */
.mt-medium {
    margin-top: 4%;
}

.mt-larger {
    margin-top: 7%;
}
/* End margin-top section */

/* Block colors section */
.color-first-block {
    background: linear-gradient(90deg, rgba(254,190,154,1) 0%, rgba(255,130,152,1) 100%);
}
/* End block colors section */

/* Circles-sections */
.upper-circle {
    width: 10%;
    height: 15%;
    border-radius: 50%;
    position: absolute;
    left: 24.5%;
    top: -0.5%;
    background: red;
}

.bottom-circle {
    width: 20%;
    height: 25%;
    border-radius: 50%;
    position: absolute;
    left: 20%;
    top: 10%;
    background: yellowgreen;

    overflow: hidden;
}

.inner-circle {
    width: 40%;
    height: 45%;
    border-radius: 50%;
    position: absolute;
    left: 25%;
    top: -3%;
    background: yellow;
}
/* End circles sections */
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/styles/reset.css">
    <link rel="stylesheet" href="./assets/styles/styles.css">
    <title>Position medium</title>
</head>
<body>
    <main>
        <!-- First block -->
        <div class="main-block color-first-block">
            <p>Weekly sales</p>
            <p class="mt-medium">$ 15.0000</p>
            <p class="mt-larger">Increased by 60%</p>

            <!-- circles section -->
            <div class="upper-circle"></div>
            <div class="bottom-circle">
                <div class="inner-circle"></div>
            </div>
            <!-- end circles section -->
        </div>
        <!-- End first block -->
    </main>
</body>
</html>

html
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-06-04 01:07:31 +0000 UTC

为什么背景中有图像的div不滚动?

  • 0

我div在一个页面上,在一个<header>显示图像(背景)、两个标题和一个按钮的标签中。

<header>
      <div class="main-section">
        <h1 class="main-label main-color">Welcome To The Beach!</h1>
        <p class="secondary-font main-color">
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Libero,
          inventore ipsum quis accusamus placeat veritatis.
        </p>
        <button class="btn main-color secondary-font">Read More!</button>
      </div>
 </header>

这个 div 绑定到 css 类.main-section,这里是它的内容:

.main-section {
    background-image: url("../img/beachshowcase.jpg");
    background-size: 100% 100%;
    /* background-size: cover; - не работает =((( */
    background-position: center;
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    text-align: center;
}

一切都以我想要的方式显示。

但是,在标签中,<main>我想放置另一个<div>带有主要信息的标签。做过这个:

<main>
  <div>
    Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi
    blanditiis sed eveniet quae, dolores aliquam eius praesentium minima
    doloremque atque nobis animi velit nulla dolore? Impedit quo fugit
    voluptatum perferendis.
  </div>
</main>

问题出现在这一点上:我只是看不到<div>tag 中的哪个<main>。这就是我想要的,但我希望滚动条会出现滚动到主要信息 - 但事实并非如此。

如何解决这个问题?

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.main-section {
  background-image: url("../img/beachshowcase.jpg");
  background-size: 100% 100%;
  /* background-size: cover; - не работает =((( */
  background-position: center;
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  text-align: center;
}

.main-color {
  --color: #926239;
  color: var(--color);
}

.main-label {
  font-size: 50px;
  line-height: 1.2;
  font-weight: bold;
  margin-bottom: 0.5%;
  margin-top: 17.5%;
}

.secondary-font {
  font-size: 20px;
}

.btn {
  margin-top: 1.5%;
  padding: 1%;
  width: 10%;
  max-width: 200px;
  border-radius: 10px;
  border-color: var(--color);
  border-width: 0.5px;
  text-align: center;
  background-color: transparent;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="./assets/styles/styles.css" />
  <title>Freshcode - Main Page</title>
</head>

<body>
  <header>
    <div class="main-section">
      <h1 class="main-label main-color">Welcome To The Beach!</h1>
      <p class="secondary-font main-color">
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Libero, inventore ipsum quis accusamus placeat veritatis.
      </p>
      <button class="btn main-color secondary-font">Read More!</button>
    </div>
  </header>

  <main>
    <div>
      Lorem ipsum dolor sit, amet consectetur adipisicing elit. Commodi blanditiis sed eveniet quae, dolores aliquam eius praesentium minima doloremque atque nobis animi velit nulla dolore? Impedit quo fugit voluptatum perferendis.
    </div>
  </main>

  <footer></footer>
</body>

</html>

它在我的浏览器中的显示方式: 在此处输入图像描述

这是问题: <div>,我插入标签中-它不可见。显然,他在页面的最开头起床,我需要他在底部,如本网站所示。

html
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-09-17 00:24:03 +0000 UTC

为什么 array_push() 在类中不起作用?

  • 0

我有一堂课。有一种方法可以添加(应该)在数组末尾添加一个新元素。相反,出现了废话。

不是一个元素,而是将 3 个元素添加到数组的末尾,并且只添加了一个第一个字符。

问题:我做错了什么?如何解决这个问题?

UPD。添加到数组末尾的内容:

我需要它而不是添加的内容,而是添加了一个条目:Ilya Kruglov 20

类.php

class Students {
.......
public $arr=array();
public function AddStud($surname, $name, $age) {
        array_push($this->arr, "$surname", "$name", "$age");
    }
}

索引.php

................
<?
include 'class.php';
$s = new Students;
$s->AddStud("Круглов", "Илья", 20);
?>

UPD2。我将信息放在这样的表格中:

<table>
<? foreach ($s->arr as $f) { ?>
    <tr>
      <td><? echo $f["Фамилия"]; ?></td>
      <td><? echo $f["Имя"]; ?></td>
      <td><? echo $f["Возраст"]; ?></td>
    </tr>
    <? } ?>
</table>
php
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2022-05-14 15:42:28 +0000 UTC

代码“TypeError:只能将列表(而不是“int”)连接到列表中的错误?

  • 0

实现牛顿法。有我不明白的错误。

deriveF_y对一个返回非整数数字的函数发誓,并且为了将该数字附加到列表中存在问题。

出了什么问题,如何纠正?

编码:

import math

def funcF(x, y):
    return((2 * x) - math.cos(y + 1)) # math.sin(x + 1) - y - 1.2

def funcG(x, y):
    return(y + math.sin(x) + 0.4) # 2 * x + math.cos(y) - 2

def derivedF_x(x):
    return(2) # math.cos(x + 1)

def derivedG_x(x):
    return (math.cos(x)) # 2

def derivedF_y(y):
    return (math.sin(y + 1)) # -1

def derivedG_y(y):
    return(1) # -math.sin(y)

def Determ(func1, func2, func3, func4):
    return(func1 * func4 - func2 * func3)

def NewtonMethod(el_x, el_y):
    e = 0.0001
    k = 0
    dN = Hn = Kn = 0
    dN = Determ(derivedF_x(el_x), derivedF_y(y), derivedG_x(x), derivedG_y(el_y))
    Hn = Determ(derivedF_y(y), funcF(el_x, el_y), derivedG_y(el_y), funcG(el_x, el_y)) / dN
    Kn = Determ(funcF(el_x, el_y), derivedF_x(el_x), funcG(el_x, el_y), derivedG_x()) / dN
    
    #Нахождение корней сис-мы
    while(abs(Hn) >= e and abs(Kn) >= e):
        el_x += Hn
        el_y += Kn
        dN = Determ(derivedF_x(el_x), derivedF_y(y), derivedG_x(x), derivedG_y(el_y))
        Hn = Determ(derivedF_y(y), funcF(el_x, el_y), derivedG_y(el_y), funcG(el_x, el_y)) / dN
        Kn = Determ(funcF(el_x, el_y), derivedF_x(el_x), funcG(el_x, el_y), derivedG_x()) / dN
        k += 1
    print("\nКорни системы:")
    print(" x =", "%.5f" % el_x, "y = ", "%.5f" % el_y)
    print("Количество итераций:", k)

arg = [-3, -2.6, -2.2, -1.8, -1.4, -1, -0.6, -0.2, 0.2, 0.6, 1]
x, y = [], []

#Заполнение значениями ф-й
for i in arg:
    y.append(math.cos(i + 1) / 2) # math.sin(i + 1) - 1.2
    x.append(-math.sin(i)-0.4) # -math.cos(i)/2 + 1

#Определение начальных точек
el_x, el_y = x[5], y[5]
print("Начальные точки приближения:\n x =", "%.2f" % el_x, "\n y =", el_y)

NewtonMethod(el_x, el_y)

错误文字:

Traceback (most recent call last):
  File "./prog.py", line 56, in <module>
  File "./prog.py", line 28, in NewtonMethod
  File "./prog.py", line 16, in derivedF_y
TypeError: can only concatenate list (not "int") to list
python
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-05-31 22:00:12 +0000 UTC

整数输入验证

  • 1

我有一个验证用户输入的函数。通过 do-while 循环实现此检查。逻辑可以有条件地分为两部分。在第一部分,我检查用户输入的数字是否是整数 (int),在第二部分,我检查这个整数是否适合我。

第二部分有效:如果您输入的整数不适合我,则会在此处显示一条错误消息,并要求您再次输入该数字。

当您输入一个非整数数字时,会发生狂欢,出现在屏幕上。

可能是什么问题呢?

在此处输入图像描述

完整功能代码:

int gameboardSize(void) {
    int size;
    bool status(false); // для проверки на ввод "нормального" размера поля, желания продолжить игру
    do {
        cout << "Введите размер игрового поля (3 - 9) -->> ";
        if (std::cin >> size) {}
        else {
            cout << "Введите число от 3 до 9 -->> ";
        }

        if (size > 2 && size < 10 && size > 0) {
            status = true;
        }
        else {
            cout << "Вы ввели неправильный размер игрового поля. Попробуйте ещё раз.\n";
        }
    } while (status != true);
    return size;
}
c++
  • 2 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-04-27 20:09:44 +0000 UTC

如何重载“+”运算符以将字符串与类对象连接起来

  • 0

我的任务是将字符串附加到类对象。我编写了代码——但它甚至没有编译,而且几乎不能正常工作。

简而言之,这就是我想做的事情:

int main() {
CString a ("первый");
a = "Это " + a;
a.Show ();
return 0;
}

结论:

Это первый

我写的函数但它不起作用(它应该是有条件的):

friend CString operator +(char* str1, CString& str2) {
    CString temp;
    strcpy(temp.c, str1);
    strcpy(temp.c, str2);
    return temp;
}

如何解决问题?不能理解。

类本身:

class CString {
private: 
    char* c;
    int length;
    CString(int leng, char* payload) { // приватный конструктор, для перегрузки конкатенации
        length = leng;
        c = payload;
    }
public:
    CString() {
        length = 0;
        c = new char[1];
        *c = 0;
    }
    CString(const char* s) { 
        length = strlen(s);
        c = new char[length + 1];
        for (int i = 0; i < length; i++) { c[i] = s[i]; }
        c[length] = '\0';
    }
    ~CString() {
        delete[] c;
    }
    CString operator +(const CString& b) {
        int newlength = length + b.length;
        char* newstr = new char[newlength + 1];
        strcpy(newstr, c);
        strcpy(newstr + length, b.c);
        return CString(newlength, newstr);
    }
    CString operator+(char* str) {
        CString temp;
        strcpy(temp.c, c);
        strcat(temp.c, c);
        return temp;
    }
    void Show(void) { cout << c << endl; }
    CString& operator =(const CString& obj) {
        delete[] c;
        length = obj.length;
        c = new char[length + 1];
        for (int i = 0; i <= length; i++) { c[i] = obj.c[i]; }
        return *this;
    }
    CString operator =(char* str) {
        CString temp;
        strcpy(c, str);
        strcpy(temp.c, c);
        return temp;
    }
    friend CString operator +(char* str1, CString& str2);
};
friend CString operator +(char* str1, CString& str2) {
    CString temp;
    strcpy(temp.c, str1);
    strcpy(temp.c, str2);
    return temp;
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-04-20 23:00:16 +0000 UTC

我不明白如何使用 splice()

  • 0

我有一个任务。我需要从列表(列表)Y 的第 5 个元素中移动列表(列表)X 的前 3 个元素。我编写了代码 - 完全是胡说八道。它甚至不编译。用谷歌搜索语法 - 用谷歌搜索它。但我什么都不懂。我什至不明白那里给出的例子是如何工作的。问:如何使用此功能?我将非常感谢初学者友好的答案。

代码本身:

cout << " 8) Переместить первые три элемента первого списка во второй список в позицию, которая начинается с пятого элемента.\n";
cout << " 8) Вывести измененный список на экран.\n";
cout << "Исходные списки:\n";
cout << "X -->> "; ShowList(X);
cout << "Y -->> "; ShowList(Y);
cout << "Изменяю список...\n"; cout << "Y -->> "; 
Y.splice(Y.begin(), X, 1, 3); // полный бред + не работает =(
ShowList(Y);
c++
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-04-16 21:25:51 +0000 UTC

矢量内容未正确写入文件

  • -1

我有几个向量。他们的元素有一个处理。底线是我必须处理元素并将它们写入文件。所以我这样做,但我得到了一些垃圾。更准确地说,我得到了我应该得到的,但同时我得到了垃圾。

我举个例子。

我有两个文件。1.txt&2.txt

内容1.txt:

4.3 2.1 5.3 20.4 1.1 200.5

2.txt是我不断上传处理结果的文件。

示例 1. 在向量 X 的末尾添加另一个元素 - 14.3

预期的:4.3 2.1 5.3 20.4 1.1 200.5 14.3

挂号的:4.3 2.1 5.3 20.4 1.1 200.5 14.3 /20.4 /Y.

示例 2:将序列 Y 的元素分配给 X 值

预期的:4.3 /2.1 /5.3 /20.4 /1.1 /200.5 /14.3

挂号的:4.3 /2.1 /5.3 /20.4 /1.1 /200.5 /14.3 /Y.

示例 3:通过值查找元素的位置(正在寻找 200.5)

预期的:Элемент найден перед 14.3

挂号的:

Элемент найден перед 14.3
00.5 /14.3 /Y.

例 5。对序列的前五个元素进行排序

预期的:1.1 /2.1 /4.3 /5.3 /14.3 /200.5 /20.4

挂号的:1.1 /2.1 /4.3 /5.3 /14.3 /200.5 /20.4 /Y.

示例 6.从第一个序列中删除最后 3 个元素

预期的:4.3 2.1 5.3

挂号的:

4.3
 2.1
 5.3
  /14.3 /200.5 /20.4 /Y.

我怀疑我错误地组织了输出。但是如何正确组织呢?是否可以制作一个可以调用的正确工作函数,以免重复相同的代码 150 次?同样,我不知道该怎么做。

直接代码:

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;

void show_vector(vector<float>& vec);

int main()
{
    setlocale(0, "");
    cout << " 1) создал пустую последовательность Х\n";
    vector<float> X;

    cout << " 2) заполнил Х из файла 1.txt\n";
    ifstream fin;
    fin.open("1.txt");
    if (!fin) cout << "\nНе могу открыть файл 1.txt для чтения.\n";
    int counter = 0;
    while (!fin.eof()) {
        X.resize(counter + 1);
        fin >> X[counter];
        counter++;
    }
    fin.close();

    cout << " 3.1) добавил ещё один элемент в конец вектора\n";
    X.push_back(14.3);

    cout << " 3.2) записал измененную последовательность в файл 2.txt\n";
    fstream fout;
    fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    for (size_t i = 0; i < X.size(); ++i) {
        fout << X[i] << " ";
    }
    fout.close();
    system("pause");

    cout << " 4) создать вторую пустую последовательность\n";
    vector<float> Y;

    cout << " 5.1) присвоил элементам второй последовательности значения первой\n";
    Y.assign(begin(X), end(X));

    cout << " 5.2) записать вторую последовательность в файл 2.txt\n";
    fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    for (size_t i = 0; i < Y.size(); ++i) {
        fout << Y[i] << " /";
    }
    fout.close();
    system("pause");

    cout << " 6) найти во второй последовательности позицию элемента, значение которого вводится с клавиатуры результат записать в файл 2.\n";
    fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    float x;
    cout << "Определите значение, позицию которого Вы хотите найти -->>  "; cin >> x;
    vector<float>::iterator i = find(Y.begin(), Y.end(), x);
    if (i == Y.end()) // если элемент не найден, то find вернет Y.end()
        fout << "Элемент не найден в последовательности Y.\n";
    else {
        fout << "Элемент найден";
        if (i == Y.begin())   cout << " - это первый элемент\n";
        else fout << " перед " << *++i << endl;
    }
    fout.close();
    system("pause");

    cout << " 7) упорядочить первые пять элементов второй последовательности и записать в 2.txt\n";
    partial_sort(Y.begin(), Y.begin()+5, Y.end());
    fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    for (size_t i = 0; i < Y.size(); ++i) {
        fout << Y[i] << " /";
    }
    fout.close();
    system("pause");

    cout << " 8) с первой последовательности удалить последние 3 элемента. Записать последовательность в 2.txt\n";
    // sort(data.begin() + m - n), data.end()); - аналог. m - начало, n - конец
    for (int i = 0; i <= 3 && !X.empty(); ++i)
        X.pop_back();

    fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    for (auto f : X) { fout << f << endl << " "; }
    fout.close();
    system("pause");

    cout << " 9) обменять содержимое первой и второй последовательности, результат вывести на экран с помощью итераторов\n";
    cout << "\nДо обмена\n" << "X -->> ";
    show_vector(X);
    cout << "\nY -->> ";
    show_vector(Y);

    X.swap(Y);
    cout << "\nПосле обмена\n" << "X -->> ";
    show_vector(X);
    cout << "\nY -->> ";
    show_vector(Y);

    cout << "\n\n 10) вычислить сумму и среднее арифметическое первой последовательности\n";
    float sum(0), avreage(0); counter = 0;
    for(size_t i = 0; i < X.size(); i++) {
        sum += X[i];
        counter++;
    }
    avreage = sum / counter;
    cout << endl << endl << "X -->> "; show_vector(X);
    cout << "\nСумма последовательности X -->> " << sum << ", среднее арифметическое последовательности X -->> " << avreage << endl;

    cout << "\n\n 11) ИЗ: поделить каждый положительный элемент вектора на минимальный элемент\n";
    cout << "\n\nX -->> ";
    show_vector(X);
    float MinElement = *min_element(X.begin(), X.end()); cout << "\nМинимальный элемент в X -->> " << MinElement << endl;
    for(size_t i = 0; i < X.size(); i++) {
        if (X[i] > 0) X[i] /= MinElement;
    }
    cout << "X -->> ";
    show_vector(X);

    cout << "\n\nY -->> ";
    show_vector(Y);
    MinElement = *min_element(Y.begin(), Y.end()); cout << "\nМинимальный элемент в Y -->> " << MinElement << endl;
    for (size_t i = 0; i < Y.size(); i++) {
        if (Y[i] > 0) Y[i] /= MinElement;
    }
    cout << "Y -->> ";
    show_vector(Y);

    return 0;
}

void show_vector(vector<float>& vec) {
    for(vector<float>::iterator it = vec.begin(); it != vec.end(); ++it)
        cout << *it << " ";
}

在所有情况下,我根据以下原则组织结论:

fsteram fout;
....
fout.open("2.txt");
    if (!fout) cout << "\nНе могу открыть или создать файл 2.txt для записи.\n";
    for (size_t i = 0; i < X.size(); ++i) {
        fout << X[i] << " ";
    }
    fout.close();
c++
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-04-13 22:47:51 +0000 UTC

类模板缺少参数列表

  • -1

我有一个简单的代码。私下里有 3 个具有模板类型的变量。公开的有3个构造函数和输入输出方法。尝试构建解决方案时 - 模板有问题。我不知道出了什么问题。

错误是:

1) E0441    отсутствует список аргументов для шаблон класса "Parallelepiped"    
2) для использования класс шаблон требуется список аргументов шаблон    
3) Ошибка   C2133   p1: неизвестный размер
4) Ошибка   C2512   Parallelepiped: нет подходящего конструктора по умолчанию

编码:

#include <iostream>
using namespace std;

template <typename T1, typename T2, typename T3>
class Parallelepiped {
private:
    T1 edge_1; // специально сделал 3 шаблона для того, чтобы работать с абсолютно разными типами
    T2 edge_2;
    T3 edge_3;
public:
    Parallelepiped() {
        edge_1 = 0;
        edge_2 = 0;
        edge_3 = 0;
        cout << "Отработал конструктор по умолчания. Ребра обнулены. Область -->> " << this << endl;
    }
    Parallelepiped(T1 e1, T2 e2, T3 e3) {
        edge_1 = e1;
        edge_2 = e2;
        edge_3 = e3;
        cout << "Отработал конструктор с параметрами. Область -->> " << this << endl;
    }
    Parallelepiped(const Parallelepiped& obj) {
        edge_1 = obj.edge_1;
        edge_2 = obj.edge_2;
        edge_3 = obj.edge_3;
        cout << "Отработал конструктор копирования. Область -->> " << this << endl;
    }
    void Initialization(void) {
        cout << "\n---------------------------------\n";
        cout << "\n\nВведите длину первого ребра параллелепипеда -->> "; cin >> edge_1;
        cout << "\n\nВведите длину второго ребра параллелепипеда -->> "; cin >> edge_2;
        cout << "\n\nВведите длину третьего ребра параллелепипеда -->> "; cin >> edge_3;
        cout << "\n---------------------------------\n";
    }
    void Show(void) {
        cout << "\n---------------------------------\n";
        cout << "\n\nДлина первого ребра параллелепипеда -->> " << edge_1;
        cout << "\n\nДлина второго ребра параллелепипеда -->> " << edge_2;
        cout << "\n\nДлина третьего ребра параллелепипеда -->> " << edge_3;
        cout << "\n---------------------------------\n";
    }
    ~Parallelepiped() {
        cout << "Отработал деструктор. Область -->> " << this << endl;
    }
};

int main()
{
    setlocale(0, "");
    Parallelepiped p1;

    return 0;
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-03-12 05:51:41 +0000 UTC

验证无法正常工作

  • 0

我有一个代码。该代码在重复..until 循环中对输入数据进行了 2 次检查。问题是:为什么这些检查不能正常工作?也就是说,文本的颜色不是红色的,即使数字在所需范围内,也始终显示文本。我也有白色的问题(注释线)。线条通常变为无色。可能是什么问题呢?

编码:

uses crt;
var a:array[1..24,1..24] of integer;
    n,m,i,j,k,v,tmp:integer; {размеры матрицы,счетчики циклов, буфер для обмена}
begin

randomize();


writeln();
writeln('------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
writeln();
writeln(' Ввод размеров матрицы....................... ');
write(' Введите количество строк n > ');
repeat
readln(n);
if (n < 1) and (n > 23) then
    textcolor(12);
    writeln('Ошибка ввода, попробуйте снова. Число строк должно быть в диапазоне от 1 до 23!');
    {textcolor(0);}
    write(' Введите количество строк n > ');
until n in [1..23]; {!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}


write(' Введите количество столбцов > ');
repeat
readln(m);
if (m < 1) and (m > 23) then
  textcolor(12);
  writeln('Ошибка ввода, попробуйте снова. Число столбцов должно быть в диапазоне от 1 до 23!');
  {textcolor(0);}
  write(' Введите количество столбцов > ');
until m in [1..23]; {!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}


writeln();
textcolor(13);
writeln('------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
writeln();
writeln('Исходная матрица:');
writeln();
writeln();

for i:=1 to n do
 begin
  for j:=1 to m do
   begin
    a[i,j]:=random(500)-250;{заполним матрицу случайными числами в инт[0,499]}
    write(a[i,j]:7);
   end;
  writeln();
 end;


writeln('------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
writeln();
{сортировка матрицы}

for k:=1 to n * m do  {повторяем сколько элементов в матрице}
for i:=1 to n do
for j:=1 to m do
   begin
    if j <> m then {если элемент в строке не последний}
      begin
       if a[i,j+1] < a[i,j]
       then
        begin
         tmp:=a[i,j+1];
         a[i,j+1]:=a[i,j];
         a[i,j]:=tmp;
        end;
       end
    else
     if (a[i+1,1] < a[i,j])and(i <> n) {если строка не последняя}
     {меняем первый элемент в следущей строке с последним элементом в текущей строке}
     then
      begin
       tmp:=a[i+1,1];
       a[i+1,1]:=a[i,j];
       a[i,j]:=tmp;
      end;
    end;


textcolor(14);
writeln('------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
writeln();
writeln('Отсортированная матрица:');
writeln();
writeln();

for i:=1 to n do
 begin
  for j:=1 to m do
  write(a[i,j]:7);
  writeln();
 end;
 writeln('------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
 writeln();
end.
pascalabc.net
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-02-27 21:09:06 +0000 UTC

无法替换主对角线以下的元素

  • 1

我需要替换矩阵 A 中主对角线下方的元素。我编写了代码,但它不能正常工作。他把左边对角线下的元素替换了,但是你需要右边=(

输入:

Введите число строк 1-й матрицы - A (<=50)--> 3
Введите число столбцов 1-й матрицы - A (<=50)--> 3
Введите 1-ю матрицу (A):
Введите A[1,1] --> 3
Введите A[1,2] --> 6
Введите A[1,3] --> 5
Введите A[2,1] --> 4
Введите A[2,2] --> 8
Введите A[2,3] --> 7
Введите A[3,1] --> 9
Введите A[3,2] --> 5
Введите A[3,3] --> 5

结论:

Матрица А.
3 6 5 
0 8 7 
0 0 5 

编码:

Const Max=50;

Var AA,BB,CC: array [1..Max,1..Max] of Double;
  ii,jj,kk,nn : integer; Summa: double;

begin
  write('Введите число строк 1-й матрицы - A (<=50)--> ');readln(NN);
  write('Введите число столбцов 1-й матрицы - A (<=50)--> ');readln(KK);
  writeln('Введите 1-ю матрицу (A):');
  for ii:=1 to nn do
  for jj:=1 to kk do
    begin
      write('Введите A[',ii,',',jj,'] --> ');
      readln(AA[ii,jj]);
    end;


    writeln();
    writeln('Заменил нулями ниже глайной диагонали < '); {заменить элементы ниже главной диагонали 0, массив А}
    for ii:=1 to nn do begin
    for jj:=1 to kk do
      if ii > jj then 
        AA[ii,jj] := 0;
    end;
    writeln();
    writeln('Матрица А.');
    for ii:=1 to nn do begin
    for jj:=1 to kk do
     write(AA[ii, jj], ' ');
    writeln;
    end;
end.

如果更短,我需要什么例如:输入:

3 6 8 4
4 4 4 4
5 5 5 5
6 6 6 6

结论:

3 6 8 4
4 4 4 0
5 5 0 0
6 0 0 0
массивы
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-02-27 13:07:53 +0000 UTC

数组元素显示不正确

  • 0

我想显示用户填写的数组元素。我想将输出组织为矩阵。问题是这不会发生。虽然,水,逻辑上一切都是如此。可能是什么问题呢?

输入:

Введите число строк 1-й матрицы - A (<=50)--> 2
Введите число столбцов 1-й матрицы - A (<=50)--> 2
Введите число столбцов 2-й матрицы - B (<=50)--> 2
Введите 1-ю матрицу (A):
Введите A[1,1] --> 1
Введите A[1,2] --> 2
Введите A[32,1] --> 
Введите A[2,2] --> 4
Введите 2-ю матрицу (B):
Введите B[1,1] --> 5
Введите B[1,2] --> 6
Введите B[2,1] --> 6
Введите B[2,2] --> 6

结论:

Матрица А.
[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица А.
[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица B.
[5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица B.
[5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица B.
[6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]Матрица B.
[6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  [6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
---- Результат: -----
   17.00   18.00
   39.00   42.00

编码:

Const Max=50;

Var AA,BB,CC: array [1..Max,1..Max] of Double;
  ii,jj,kk,nn,mm,ll : integer; Summa: double;

begin
  write('Введите число строк 1-й матрицы - A (<=50)--> ');readln(NN);
  write('Введите число столбцов 1-й матрицы - A (<=50)--> ');readln(KK);
  write('Введите число столбцов 2-й матрицы - B (<=50)--> ');readln(MM);
  writeln('Введите 1-ю матрицу (A):');
  for ii:=1 to nn do
  for jj:=1 to kk do
    begin
      write('Введите A[',ii,',',jj,'] --> ');
      readln(AA[ii,jj]);
    end;

  writeln('Введите 2-ю матрицу (B):');
  for ii:=1 to kk do
  for jj:=1 to mm do
   begin write('Введите B[',ii,',',jj,'] --> '); readln(BB[ii,jj]);
   end;

   {проблема}
   for ii:=1 to nn do
   for jj:=1 to kk do
   begin
     writeln('Матрица А.');
     write(AA[ii], '  ', AA[jj]);
   end;

   for ii:=1 to kk do
   for jj:=1 to mm do
   begin
     writeln('Матрица B.');
     write(BB[ii], '  ', BB[jj]);
   end;

  {Вычисляем элементы матрицы-результата}

    for ii:=1 to nn do
    for jj:=1 to mm do
      begin
        Summa:= 0;
        for ll:= 1 to kk do
          Summa:= Summa + AA[ii,ll]*BB[ll,jj];
          CC[ii,jj] := Summa;
      end;
{Выводим матрицу-результат:}
  writeln();
  writeln('---- Результат: -----');
  for ii:=1 to nn do
    begin
      for jj:=1 to mm do
        write(CC[ii,jj]:8:2);
      writeln;
    end;
readln;
end.
массивы
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-02-27 03:45:09 +0000 UTC

组织数组元素输出的问题

  • 1

我需要填写 PRNG 向量。我做的。接下来,按以下顺序打印数组的元素:

a1,a10,a2,a11...a9,a18

我写的代码只按照我想要的顺序找到前两个元素。也就是说,a1,a10 这是因为步骤 (i) 变为 > N。我真的需要关于如何解决这个问题的帮助。

编码:

const Sz = 100; // Размер массива

var 
  a: array [1..Sz] of real;
  N: integer; // Количество элементов в массиве
  i: integer;

begin
  N := 18;
  for i:=1 to N do
    a[i] := Random(100) * 0.6;

  write('Сгенерированные элементы массива > ');
  for i:=1 to N do
    begin
    if i <> N then
      write(i, ') ', a[i],'; ');
    if i = N then
      writeln(i, ') ', a[i],'. ');
    end;
    writeln();

    write('Искомые элементы > ');
    i := 1;
    while N >= i do
      begin
      if i <> N then
      write(i, ') ', a[i],'; ');
      if i = N then {проверка на последний элемент, для точки}
      writeln(i, ') ', a[i],'. ');
      i+=9;
    end;

end.
массивы
  • 1 个回答
  • 10 Views
Martin Hope
dbUser11
Asked: 2020-02-25 03:44:08 +0000 UTC

函数不返回任何值[关闭]

  • -1
关闭 这个问题是题外话。目前不接受回复。

该问题是由不再复制的问题或错字引起的。虽然类似的问题可能与本网站相关,但该问题的解决方案不太可能帮助未来的访问者。通常可以通过在发布问题之前编写和研究一个最小程序来重现问题来避免此类问题。

2年前关闭。

改进问题

有两个数组。有一个重载函数应该计算这些数组元素的算术平均值。回报应该工作。它是,但不起作用。可能是什么问题呢?

编码

#include <iostream>
using namespace std;

double func(double * mas, int kol);
float func(float * mas, int kol);

void main() {
 setlocale(0, "");
 const int kol = 5;
 double mas[kol];
 float mas1[kol];

 for(int i = 0; i < kol; i++) {
  cout << " Введите " << i + 1 << " елемент double массива > ";
  cin >> mas[i];
  cout << " Введите " << i + 1 << " елемент float массива > ";
  cin >> mas1[i];
 }
 func(mas, kol);
 func(mas1, kol);
 system("pause");
}

double func(double * mas, int kol) {
 double sum = 0;
 for(int i = 0; i < kol; i++) {
  sum += mas[i];
 }
 printf("Среднее арифметическое double массива > \n");
 return sum/kol;
}

float func(float * mas1, int kol) {
 float sum = 0;
 for(int i = 0; i < kol; i++) {
  sum += mas1[i];
 }
 printf("Среднее арифметическое float массива > \n");
 return sum/kol;
}
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