#include <stdio.h> int main() { int n, max = 0; printf("podaj n - "); scanf("%d",&n); int tabP[n-1]; for(int i = 0; i < n; i++){ scanf("%d",&tabP[i]); if(tabP[i]-1 > max){ max = tabP[i]-1; } } int tab[n-1]; for(int i = n - 1; i > -1; i--){ tab[i] = i; } int tabLider[n]; for(int i = 0; i < n; i++){//działa for(int j = 0; j < n; j++){ if(tabP[j] == tab[i]){ tabLider[i]++; } } } int max1 = 0; printf("\n"); for(int i = 0; i < n; i++){ if(max1 < tabLider[i]){ max1 = tab[i]; } } printf("%d",max1); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <stdio.h> int main() { int n, max = 0; printf("podaj n - "); scanf("%d",&n); int tabP[n-1]; for(int i = 0; i < n; i++){ scanf("%d",&tabP[i]); if(tabP[i]-1 > max){ max = tabP[i]-1; } } int tab[n-1]; for(int i = n - 1; i > -1; i--){ tab[i] = i; } int tabLider[n]; for(int i = 0; i < n; i++){//działa for(int j = 0; j < n; j++){ if(tabP[j] == tab[i]){ tabLider[i]++; } } } int max1 = 0; printf("\n"); for(int i = 0; i < n; i++){ if(max1 < tabLider[i]){ max1 = tab[i]; } } printf("%d",max1); return 0; } |