package com.company;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Введите размер массива: ");
int size = sc.nextInt();
int[] myArray = new int[size];
System.out.print("Заполните элементы массива: ");
for(int i=0; i<size; i++) {
myArray[i] = sc.nextInt();
}
System.out.print("Одинаковые элементы: ");
for(int i=0; i<myArray.length; i++) {
for (int j=i+1; j<myArray.length; j++) {
if(myArray[i] == myArray[j]) {
System.out.println(j);
}
}
}
}
}
Объяснение:
Я использую язык программирования java, думаю переписать на нужный вам вы сможете.
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define N 5
#define M 10
int main(){ int a[N][M],i,j,Sum=0;
srand((unsigned)time(NULL));
for (i=0;i<N;i++){
for(j=0;j<M;j++){
a[i][j]=rand()%10+1;
} };
for (i=0;i<N;i++){
for(j=0;j<M;j++){
Sum=pow(a[i][j],3)+Sum;
} };
printf("%d",Sum);
getch ();
return 0;
}