Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cstdlib>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. struct Complex{
  9. int real;
  10. double imaginar;
  11. }x;
  12.  
  13. void citire(struct Complex **x, int n, int m)
  14. {
  15. int i=0, j=0;
  16. for(i=0;i<n;i++)
  17. {
  18. for(j=0;j<m;j++)
  19. {
  20. cout << "Elementul [" << i+1 << "][" << j+1 << "]: " << endl;
  21. cin >> x[i][j].real;
  22. cin >> x[i][j].imaginar;
  23. }
  24. }
  25. }
  26.  
  27. void afisare(struct Complex **x, int n, int m)
  28. {
  29. int i=0, j=0;
  30. for(i=0;i<n;i++)
  31. {
  32. for(j=0;j<m;j++)
  33. {
  34. cout << x[i][j].real << ' ' << x[i][j].imaginar << ' ' << endl;
  35. }
  36. }
  37. }
  38.  
  39. int main()
  40. {
  41. struct Complex **x;
  42. int n=0,m=0;
  43. cout << "Cate linii ? "; cin >> n;
  44. cout << "Cate coloane ? "; cin >> m;
  45. x = (Complex**) malloc (n*m * sizeof (Complex));
  46. for (int i = 0; i < n; i++)
  47. {
  48. x[i] = (Complex*) malloc (n * sizeof (Complex));
  49. }
  50. citire(x,n,m);
  51. afisare(x,n,m);
  52. return 0;
  53. }
  54.  
  55. ///1.main -> matrice tip complex din u x u struct parte reala, imaginara (double)
  56. ///citeste matricea
  57. ///f. cautare un element comlex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement