Advertisement
Guest User

Untitled

a guest
May 29th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. typedef struct
  5. {
  6. float Re, Im;
  7. }Complex;
  8.  
  9. int CitajNiz(char name[], Complex niz[])
  10. {
  11. int n=0;
  12. FILE *in;
  13. Complex k;
  14.  
  15. in=fopen(name, "r");
  16. if(in==NULL)
  17. return 0;
  18. while(1)
  19. {
  20. fscanf(in,"%f%f", &k.Re, &k.Im);
  21. if(feof(in)) break;
  22. niz[n]=k;
  23. n++;
  24. }
  25. fclose(in);
  26. return n;
  27. }
  28.  
  29. float Moduo(Complex k)
  30. {
  31. return sqrt(pow(k.Re,2)+pow(k.Im,2));
  32. }
  33.  
  34. main()
  35. {
  36. Complex niz1[100], niz2[100];
  37. int n1, n2;
  38.  
  39. n1=CitajNiz("ulaz1.txt", niz1);
  40. n2=CitajNiz("ulaz2.txt", niz2);
  41.  
  42. getch();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement