Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. void dynamic_array(int wymiar_poziomy, int wymiar_pionowy) {
  2. int i = 0, j = 0, suma = 0, liczba = 0;
  3.  
  4.  
  5. int **poziom;
  6. poziom = (int**)malloc(wymiar_poziomy * sizeof(int*));
  7.  
  8.  
  9.  
  10.  
  11. for (i = 0; i < wymiar_poziomy; i++) {
  12.  
  13. poziom[i] = (int*)malloc(wymiar_pionowy * sizeof(int));
  14.  
  15. for (j = 0; j < wymiar_pionowy; j++) {
  16. int wartosc = 0;
  17. scanf("%d", &wartosc);
  18. poziom[i][j] = wartosc;
  19. suma = suma + wartosc;
  20. }
  21. if (suma % 2 == 0) {
  22. liczba++;
  23. suma = 0;
  24. }
  25. else
  26. {
  27. suma = 0;
  28. }
  29. }
  30.  
  31.  
  32. for (i = 0; i < wymiar_poziomy; i++) {
  33.  
  34. for (j = 0; j < wymiar_pionowy; j++) {
  35. printf("%d", poziom[i][j]);
  36. }
  37. puts("");
  38.  
  39. }
  40. printf("Liczba wierszow o parzystej liczbie elemntow wynosi: %d", liczba);
  41. system("PAUSE");
  42. }
  43.  
  44. int main()
  45. {
  46. int a, b;
  47. printf("Podaj wymiar macierzy. Zacznij od PION a nastepnie POZIOM");
  48. scanf("%d", &a);
  49. scanf("%d", &b);
  50.  
  51. dynamic_array(b, a);
  52.  
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement