<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Даны два массива. Сформировать массив, содержащий отриц. числа]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=9751&amp;type=atom" />
	<updated>2014-06-30T14:24:29Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=9751</id>
		<entry>
			<title type="html"><![CDATA[Re: Даны два массива. Сформировать массив, содержащий отриц. числа]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=84367#p84367" />
			<content type="html"><![CDATA[<p>Дело в том, что мы еще мало что изучали и препод просит делать это все селсами и всякой вот такой мишурой. Я уже сделал. Спасибо)</p>]]></content>
			<author>
				<name><![CDATA[dimkar1]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32393</uri>
			</author>
			<updated>2014-06-30T14:24:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=84367#p84367</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Даны два массива. Сформировать массив, содержащий отриц. числа]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=84366#p84366" />
			<content type="html"><![CDATA[<p>Вариантов масса. С точки зрения производительности, расхода памяти, наглядности кода… Например:<br /></p><div class="codebox"><pre><code>Option Explicit

Sub Sample()
    Dim a(1 To 10) As Double
    Dim b(1 To 5) As Double
    
    Dim c() As Double
    ReDim c((UBound(a) - LBound(a)) + (UBound(b) - LBound(b)) + 1)
    
    Dim i As Integer
    Dim j As Integer
    
    Dim iNegativeCount As Integer
    
    Debug.Print &quot;=== First array ===&quot;
    For i = LBound(a) To UBound(a)
        a(i) = CDbl(Rnd() * 100 - 50)
        Debug.Print i, a(i)
    Next
    Debug.Print
    
    Debug.Print &quot;=== Second array ===&quot;
    For i = LBound(b) To UBound(b)
        b(i) = CDbl(Rnd() * 100 - 50)
        Debug.Print i, b(i)
    Next
    Debug.Print
    
    iNegativeCount = 0
    
    j = LBound(c)
    
    For i = LBound(a) To UBound(a)
        If a(i) &lt; 0 Then
            iNegativeCount = iNegativeCount + 1
            c(j) = a(i)
            j = j + 1
        End If
    Next
    
    For i = LBound(b) To UBound(b)
        If b(i) &lt; 0 Then
            iNegativeCount = iNegativeCount + 1
            c(j) = b(i)
            j = j + 1
        End If
    Next
    ReDim Preserve c(iNegativeCount - 1)
    
    Debug.Print &quot;=== Result array ===&quot;
    For i = LBound(c) To UBound(c)
        Debug.Print i, c(i)
    Next
End Sub
</code></pre></div><p>А причём тут «.Cells()»?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-06-30T13:49:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=84366#p84366</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Даны два массива. Сформировать массив, содержащий отриц. числа]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=84364#p84364" />
			<content type="html"><![CDATA[<p>Есть два массива. Нужно сделать третий массив, который состоит только из отрицательных чисел. Как это сделать?<br />P и K это количество отрицательных чисел в каждом массиве. Z - общее количество отриц. чисел. Но вот дальше не знаю.. Завтра защита в универе. Помогите, пжл</p><div class="codebox"><pre><code>

Sub Pan_6()
Cells.ClearContents
Dim p As Byte
Const M = 10
Const N = 5
Dim A(1 To M) As Double
Dim B(1 To N) As Double



Dim i As Byte
Dim j As Byte

For i = 1 To M
A(i) = InputBox(&quot;Введите элемент массива A(&quot; &amp; i &amp; &quot;)&quot;)
Cells(2, 1 + i).Value = A(i)
Cells(1, 1 + i).Value = &quot;A(&quot; &amp; i &amp; &quot;)&quot;
Next i

For j = 1 To N
B(j) = InputBox(&quot;Введите элемент массива B(&quot; &amp; j &amp; &quot;)&quot;)
Cells(4, 1 + j).Value = B(j)
Cells(3, 1 + j).Value = &quot;B(&quot; &amp; j &amp; &quot;)&quot;

Next j

k = 0
For i = 1 To M
    If A(i) &lt; 0 Then
    k = k + 1
    End If
Next i

p = 0
For j = 1 To N
    If B(j) &lt; 0 Then
    p = p + 1
    End If
Next j


z = p + k</code></pre></div>]]></content>
			<author>
				<name><![CDATA[dimkar1]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32393</uri>
			</author>
			<updated>2014-06-30T11:35:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=84364#p84364</id>
		</entry>
</feed>
