Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 15
  4. int main()
  5. {
  6. int tab[N];
  7. int i;
  8. srand(time(NULL));
  9. for(i=0; i<N; ++i){
  10. tab[i] = rand()%100;
  11. printf("%d ", tab[i]);
  12. }
  13. printf("\n\nLiczby o parzystych indeksach to:\n");
  14. for(i=0; i<N; ++i){
  15. if(i%2==0){
  16. printf("%d ", tab[i]);
  17. }
  18. }
  19. printf("\n\nLiczby o nieparzystych indeksach to:\n");
  20. for(i=0; i<N; ++i){
  21. if(i%2==1){
  22. printf("%d ", tab[i]);
  23. }
  24. }
  25. printf("\n\nElementy tablicy w odwrotnej kolejnosci:\n");
  26. for(i=N-1; i>=0; --i){
  27. printf("%d ", tab[i]);
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement