Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #define n 5
  5.  
  6.  
  7. typedef struct {
  8. double Re;
  9. double Im;
  10. } complex_t;
  11.  
  12. int main()
  13. {
  14. srand(time(0));
  15.  
  16. complex_t *wsk;
  17. complex_t *wsk2;
  18.  
  19. wsk = calloc(wsk, n*sizeof(complex_t));
  20. wsk2 = calloc(wsk, n*sizeof(complex_t));
  21.  
  22. for(int i=0; i<n; i++)
  23. {
  24. wsk[i].Re = rand()%10;
  25. wsk[i].Im = rand()%10;
  26. }
  27.  
  28. for(int i=0; i<n; i++)
  29. {
  30. wsk2[i].Re = wsk[i].Im;
  31. wsk2[i].Im = wsk[i].Re;
  32. }
  33.  
  34. for(int i=0; i<n; i++)
  35. {
  36. printf("%f %f\n", wsk[i].Re, wsk[i].Im);
  37. printf("%f %f\n", wsk2[i].Re, wsk2[i].Im);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement