Advertisement
Guest User

xdd1231214

a guest
Jan 23rd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. // ConsoleApplication27.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10. void czytaj(int tab[]) {
  11.     for (int i = 0; i < 10; i++) {
  12.         cout << tab[i] << " ";
  13.     }
  14.     cout << endl;
  15. }
  16.  
  17. void reverse(unsigned int n, int tab[]) {
  18.     for (int i = 0; i < n / 2; i++) {
  19.         int pom = tab[i];
  20.         tab[i] = tab[n - 1 - i];
  21.         tab[n - 1 - i] = pom;
  22.     }
  23. }
  24.  
  25. int main()
  26. {
  27.     int n = 5;
  28.     int tab[10];
  29.     srand(time(NULL));
  30.     for (int i = 0; i < 10; i++) {
  31.         tab[i] = rand();
  32.     }
  33.     czytaj(tab);
  34.     reverse(n, tab);
  35.     czytaj(tab);
  36.     system("pause");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement