#include "stdafx.h" #include #include #include int diff_numbers(int *a,int n) //How many different numbers in a sorted array { int diff=0; for(int i=0 ; ia[i+1]) return false; return true; } bool test_permutation(int *a,int n,int *numbers,int *counters,int diff) //True if all numbers in presorted array do appear in the sorted array { for(int i=0 ; iarr[i+gap]) { int tmp=arr[i]; arr[i]=arr[i+gap]; arr[i+gap]=tmp; s_f=1; } } } gap=gap/2; } } const int N=10000; void main(void) { int a[N],b[N]; for(int i=0 ; imax_counters) { max_counters=counters[i]; max_numbers=numbers[i]; } } printf("\nIn the array:\n"); printf("The number %d appears the least number of times with %d appearances\n", min_numbers, min_counters); printf("The number %d appears the most number of times with %d appearances\n", max_numbers, max_counters); printf("\n"); if(test_permutation(a,N,numbers,counters,diff)) printf("\nOK"); else printf("\nNot OK"); _getch(); } /* numbers counters -10 462 -9 469 -8 466 -7 470 -6 498 -5 456 -4 476 -3 465 -2 474 -1 535 0 505 1 474 2 458 3 483 4 471 5 458 6 463 7 488 8 492 9 448 10 489 In the array: The number 9 appears the least number of times with 448 appearances The number -1 appears the most number of times with 535 appearances OK */