avukas

Kompleksni- modul

Sep 10th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. struct Kompleksni
  6. {
  7.     float re, im;
  8. };
  9.  
  10. struct Kompleksni *funkcija(struct Kompleksni niz[], int *velicina)
  11. {
  12.     int i, max = 0, min = 9, modul;
  13.     for (i=0; i<*velicina; i++)
  14.     {
  15.         modul = sqrt((niz[i].re) * (niz[i].re) + (niz[i].im*niz[i].im));
  16.         if (modul > max)
  17.             max = modul;
  18.         if (modul < min)
  19.             min = modul;
  20.     }
  21.  
  22.     return max+min;
  23. }
  24.  
  25. int main()
  26. {
  27.     struct Kompleksni niz[6]={{1,2}, {6,5}, {2,1},{4,5}, {7,1},{2,0}};
  28.     int velicina=6, i;
  29.     struct Kompleksni novi[6];
  30.     struct Kompleksni *pok = novi;
  31.     pok = funkcija(niz, &velicina);
  32.  
  33.     printf("%d", pok );
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment