Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef int funkcija(int*, int);
- int minimum(int*, int);
- int maksimum(int*, int);
- int sumaBezEkstrema(int*, int, funkcija*);
- int main()
- {
- int niz[50]={20, -30, 4, 15, -30, 20, 20, 5}, n=8;
- int suma = sumaBezEkstrema(niz,n,minimum);
- printf("Suma: %d",suma);
- return 0;
- }
- int minimum(int* niz, int n)
- {
- int i, min=*niz;
- for(i=0;i<n;i++){
- if(niz[i]<min) min=niz[i];
- }
- return min;
- }
- int maksimum(int* niz, int n)
- {
- int i, max=*niz;
- for(i=0;i<n;i++){
- if(niz[i]>max) max=niz[i];
- }
- return max;
- }
- int sumaBezEkstrema(int* niz, int n, funkcija* fun)
- {
- int i, suma=0;
- for(i=0;i<n;i++){
- if(niz[i]!=(*fun)(niz,n)) suma+=niz[i];
- }
- return suma;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement