Array10. Дан целочисленный массив размера N. Вывести вначале все содержащиеся в данном массиве четные числа в порядке возрастания их индексов, а затем − все нечетные числа в порядке убывания их индексов.
>Решение Pascal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | program Array10; var a:array[1..10] of integer; N,i:Integer; begin Write('N:'); Readln(N); for i:=1 to N do begin write(i,' :'); readln(a[i]); end; for i:=1 to N do if i mod 2 = 0 then writeln(i,' : ',a[i]); for i:=N downto 1 do if i mod 2 <> 0 then writeln(i,' : ',a[i]); end. |
>
Решение C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> int main(void) { int a[10]; int n, i; printf("N: "); scanf("%i",&n); for (i=0; i<n; ++i){ printf("a[%i] : ",i); scanf("%i",&a[i]); } for (i=0; i<n; ++i) if (a[i]%2 == 0) printf("%i\n",a[i]); for (i=n-1; i>=0; --i) if (a[i]%2 != 0) printf("%i\n",a[i]); return 0; } |
#include bits/stdc++.h
using namespace std;
int main()
{
srand(time(0));
int n;
cin >> n;
int ar[n];
for (int i = 0;i < n;++i)
{
ar[i] = rand() % 90 + 10;
cout << ar[i] << " ";
}
cout << endl;
for (int i = 0;i < n;++i)
{
if ((ar[i] + 1) % 2)
{
cout << ar[i] << " ";
}
}
cout <= 0;—i)
{
if (ar[i] % 2)
{
cout << ar[i] << " ";
}
}
return 0;
}
c++
int main()
{
int n;
cin >> n;
int arr[100];
for (int i = 0; i > arr[i];
}
cout << endl;
for (int i = 0; i < n; i++)
if (arr[i] % 2 == 0)
{
cout << arr[i] << endl;
}
else
continue;
cout <= 0; i—)
if (arr[i] % 2 == 1)
{
cout << arr[i] << endl;
}
else
continue;
}
ты вообще что написал ………
это что такое ? капеееец
Java iltimos.
JAVA
import java.util.Scanner;
public class arr10 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(«Enter N: «);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
for (int i = 0; i < a.length; i++) {
if (a[i] % 2 == 0) {
System.out.print(a[i] + " ");
}
}
for (int i = 0; i < a.length; i++) {
if (a[i] % 2 == 1) {
System.out.print(a[i] + " ");
}
}
}
}
ok
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
for (int i = 0; i = 0; i—) {
if (i % 2 != 0) {
System.out.print(arr[i] + » «);
}
}
System.out.println();