Sub aaa() Rows.Clear Dim n As Integer, k As Integer, i As Integer n = CInt(InputBox("n=")) k = 2 * n - 1 ReDim y(1 To k) As Integer Randomize Timer For i = 1 To k y(i) = Int(Rnd * 100 - 50) Next i Dim ry As Range Set ry = Range(Cells(2, 2), Cells(2, k + 1)) ry = y ReDim x(1 To n) As Integer Dim rx As Range Set rx = Range(Cells(3, 2), Cells(3, n + 1)) For i = 1 To n x(i) = y(2 * i - 1) ^ 2 Next i rx = x Cells(2, 1) = "y" Cells(3, 1) = "x" Set ry = Range(Cells(2, 1), Cells(2, k + 1)) Set rx = Range(Cells(3, 1), Cells(3, n + 1)) End Sub
Using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Random r = new Random(); int[] a = new int[50]; int k = 0; for(int i = 0;i<50;i++) { a[i] = r.Next(1001); Console.WriteLine("a[" + i + "] =" + a[i]); } for (int i = 0; i < 49; i++) { if (a[i]+a[i+1] <= 217) { k++; } } Console.WriteLine("Кол-во пар :" + k); Console.ReadKey(); } } }
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку