Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- using namespace std;
- //https://pastebin.com/AM7CGswP
- //https://pastebin.com/SzwN5JKN
- //https://pastebin.com/CDzc1TXw
- void sortowanie(float t[], int n)
- {
- //sortowanie bąbelkowe
- for (int i=0; i<n-1; i++)
- for (int j=i+1; j<n; j++)
- {
- if ( t[i] > t[j] ) {
- float r = t[i];
- t[i] = t[j];
- t[j] = r;
- }
- }
- }
- void wyswietlanie(float t[], int n)
- {
- for (int i=0; i<n; i++) {
- cout << t[i] << " ";
- }
- cout << endl;
- }
- void losuj(float t[], int n)
- {
- for (int i=0; i<n; i++)
- t[i] = rand() % 20 + 1;
- }
- void losuj(float t[], int n, int zakres_min, int zakres_max)
- {
- int zakres = zakres_max-zakres_min;
- for (int i=0; i<n; i++)
- t[i] = rand() % zakres + zakres_min;
- }
- float suma(float t[], int n)
- {
- float s = 0;
- for (int i=0; i<n; i++) {
- s = s + t[i];
- }
- return s;
- }
- float mediana(float t[], int n) {
- sortowanie(t,n);
- return t[n/2];
- }
- int main()
- {
- //alokowanie pamięci na potrzeby tablicy
- float *tab;
- int N = 100000000;
- //!!!
- tab = new float[N];
- losuj(tab, N);
- wyswietlanie(tab, N);
- sortowanie(tab, N);
- wyswietlanie(tab, N);
- //!!!
- delete [] tab;
- // nieobowiązkowe
- int * a;
- a = new int;
- cout << a << endl;
- *a = 10;
- cout << *a << endl;
- delete a;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement