Good day.
There is a one-dimensional array of 10 elements (positive and negative) that are generated randomly.
It is required to find the product of identical negative elements, i.e. check the elements for negativity, get the values of the elements that are repeated 2 or more times, build this number in the number of repetitions of this number, output.
For example, an array: -1 2 -3 -5 -3 4 -3 -5 2 6
It turns out: -3 is repeated 3 times, -5 is repeated 2 times. It is necessary to calculate -3 ^ 3 and -5 ^ 2 and output: what number is repeated, how many times and the result (-27 and 25, respectively).
Initial array generation:
#include <stdio.h> #include <windows.h> #include <stdlib.h> #include <time.h> int main() { system("cls");; int ARR[10], i, j, num=0, P=1; srand(time(NULL)); printf("Array:\n"); for(i=0; i<10; i++) { ARR[i]=rand() % 11 - 7; printf("%i\t", ARR[i]); } /* */ } I studied several similar topics, but none of the codes worked correctly. Which way to dig?
Thank.


qsort- sorted. We go from the minimum. If there are identical negative ones next to each other - we consider, we deduce (just note that (-5) ^ 2 is 25, not -25 :)). Run out of negative numbers - stopped ... - Harry