Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. void wypelnienie(double macierz[4][3]){
  6.  
  7.  
  8. int x, y, p=-11, q=11;
  9.  
  10. srand(time(0));
  11. for (x = 0; x < 4; x++) {
  12. for (y = 0; y < 3; y++) {
  13. macierz[x][y] = p + (double) rand()/ RAND_MAX*(q-p);
  14. }
  15. }
  16.  
  17.  
  18.  
  19. }
  20.  
  21. void wypisaniePrzed(double macierz[4][3]){
  22.  
  23.  
  24. int x, y;
  25.  
  26. printf("\n");
  27. for(x = 0; x<4; x++){
  28. for(y=0; y<3; y++)
  29. printf("%lf\t",macierz[x][y]);
  30. printf("\n");
  31. }
  32. printf("\n");
  33. }
  34.  
  35. void wypisaniePo(double macierz[4][3]){
  36.  
  37.  
  38. int liczba;
  39. printf("Wprowadz liczbe przez ktora chcesz pomnozyc tablice \n");
  40.  
  41. scanf("%d", &liczba);
  42.  
  43.  
  44. int x, y;
  45.  
  46. printf("\n");
  47. for(x = 0; x<4; x++){
  48. for(y=0; y<3; y++)
  49. macierz[x][y] = liczba * macierz[x][y];
  50. }
  51. }
  52.  
  53. printf("Wypisanie po przemnozeniu: \n");
  54.  
  55. printf("\n");
  56. for(x = 0; x<4; x++){
  57. for(y=0; y<3; y++)
  58. printf("%lf\t",macierz[x][y]);
  59. printf("\n");
  60. }
  61. printf("\n");
  62.  
  63.  
  64. int main()
  65. {
  66. double macierz[4][3];
  67. wypelnienie(macierz);
  68. wypisaniePrzed(macierz);
  69. wypisaniePo(macierz);
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement