Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- using namespace std;
- int Count(double* arr, const int size)
- {
- int temp = 0;
- for (int i = 0; i < size; ++i)
- {
- if (arr[i] == int(arr[i]))
- {
- temp++;
- }
- }
- return temp;
- }
- double Min(double* arr, const int size)
- {
- double min = arr[0];
- for (int i = 0; i < size; i++)
- {
- if (arr[i] < min)
- {
- min = arr[i];
- }
- }
- return min;
- }
- double Max(double* arr, const int size)
- {
- double max = arr[0];
- for (int i = 0; i < size; i++)
- {
- if (arr[i] > max)
- {
- max = arr[i];
- }
- }
- return max;
- }
- void Sort(double* arr, const int size)
- {
- if (arr && size > 0)
- {
- double xx;
- int j;
- for (int i = size - 2; i >= 0; --i)
- {
- xx = arr[i];
- j = i + 1;
- while (j < size && xx > arr[j])
- {
- arr[j - 1] = arr[j];
- j++;
- }
- arr[j - 1] = xx;
- }
- }
- }
- void PrintTab(double* arr, const int size)
- {
- printf("tablica = [");
- for (int i = 0; i < size; i++)
- {
- printf("%.2f ,", arr[i]);
- }
- printf("]\n");
- }
- int main()
- {
- int size;
- printf("Podaj wymiar tablicy: ");
- scanf("%d", &size);
- double* tab = new double[size];
- for (int i = 0; i < size; i++)
- {
- printf("Podaj %d element tablicy: ", i + 1);
- scanf("%lf", &tab[i]);
- //cout << "Podaj " << i + 1 << " element tablicy: ";
- //cin >> tab[i];
- }
- PrintTab(tab, size);
- printf("Maximum: %lf \n", Max(tab, size));
- printf("Minimum: %lf \n", Min(tab, size));
- printf("Ilosc liczb calkowitych: %d \n", Count(tab, size));
- Sort(tab, size);
- PrintTab(tab, size);
- delete[] tab;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement