Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 5
  4. int main()
  5. {
  6. int A[N];
  7. int B[N];
  8. int C[N];
  9. int D[N];
  10. unsigned long int ils =0;
  11. int i;
  12. srand(time(NULL));
  13. for(i=0; i<N; ++i){
  14. A[i] = rand()%100;
  15. B[i] = rand()%100;
  16. C[i] = A[i] + B[i];
  17. D[i] = A[i] * B[i];
  18. ils += A[i]*B[i];
  19. }
  20.  
  21. printf("Elementy wektoru A:\n");
  22. for(i=0; i<N; ++i){
  23. printf("%d ", A[i]);
  24. }
  25. printf("\n\nElementy wektoru B:\n");
  26. for(i=0; i<N; ++i){
  27. printf("%d ", B[i]);
  28. }
  29. printf("\n\nWektor bedacy suma wektorow A i B:\n");
  30. for(i=0; i<N; ++i){
  31. printf("%d ", C[i]);
  32. }
  33. printf("\n\nWektor bedacy iloczynem wektorow A i B:\n");
  34. for(i=0; i<N; ++i){
  35. printf("%d ", D[i]);
  36. }
  37. printf("\n\nIloczyn skalarny wektorow A i B wynosi: %lu\n", ils);
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement