Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /*4. (0,5 bodova) Napisati funkciju matrice_permutacija koja prima tri matrice A, B i C istih dimenzija MxN te
  2. vraća logičku istinu ako sve tri matrice sadrže iste elemente sa istim brojem ponavljanja, a logičku neistinu u
  3. suprotnom. Prototip funkcije glasi:
  4.  
  5. int matrice_permutacija(double A[100][100], double B[100][100],
  6. double C[100][100], int M, int N)
  7.  
  8. Napišite i main funkciju pomoću koje se možete uvjeriti da je navedena funkcija ispravna. */
  9. #include <stdio.h>
  10. #define EPS 0.0001
  11.  
  12. int matrice_permutacija(double A[][100], double B[][100], double C[][100], int M, int N){
  13. int i, j;
  14. for(i=0;i<M;i++){
  15. for(i=0;j<N;j++){
  16. if(A[i][j]-B[i][j]>EPS || A[i][j]-C[i][j]>EPS)
  17. return 0;
  18. }
  19. }
  20. return 1;
  21. }
  22. int main() {
  23. double A[100][100], B[100][100], C[100][100];
  24. int M, N, i, j, x;
  25. printf("Unesite M i N: \n");
  26. scanf("%d %d", &M, &N);
  27. printf("Elementi prve matrice: \n");
  28. for(i=0;i<M;i++){
  29. for(j=0;j<N;j++){
  30. scanf("%lf", &A[i][j]);
  31. }
  32. }
  33. printf("Elementi druge matrice: \n");
  34. for(i=0;i<M;i++){
  35. for(j=0;j<N;j++){
  36. scanf("%lf", &B[i][j]);
  37. }
  38. }
  39. printf("Elementi trece matrice: \n");
  40. for(i=0;i<M;i++){
  41. for(j=0;j<N;j++){
  42. scanf("%lf", &C[i][j]);
  43. }
  44. }
  45. x=matrice_permutacija(A,B,C,M,N);
  46. printf("%d", x);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement