Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int GetMax(int x[], int arraySize)
- {
- int currentMax = 0;
- for (int i = 0; i < arraySize; i++)
- {
- int currentArrayElement = x[i];
- if (currentMax < currentArrayElement)
- {
- currentMax = currentArrayElement;
- }
- }
- return currentMax;
- }
- void SortArray(int x[], int arraySize)
- {
- bool isOk = true;
- do
- {
- isOk = true;
- for (int i = 0; i < arraySize - 1; i++)
- {
- if (x[i] > x[i + 1])
- {
- int tmpX = x[i];
- x[i] = x[i + 1];
- x[i + 1] = tmpX;
- isOk = false;
- }
- }
- } while (!isOk);
- }
- int main()
- {
- const int arraySize = 5;
- int a[arraySize] = { 11,25,23,14,5 };
- //int max = GetMax(a, arraySize);
- SortArray(a, arraySize);
- //cout << "Max value is - " << max << "\n";
- for (int i = 0; i < arraySize; i++)
- {
- cout << a[i] << "\t";
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement