Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; unsigned const n = 8; void input(int array[]) { int t; for (int i = 0; i < n; ++i) { cout << "Podaj " << i + 1 << " element: "; cin >> t; array[i] = t; } } void output(int array[]) { cout << "["; for (int i = 0; i + 1 < n; ++i) cout << array[i] << ", "; cout << array[n - 1] << "]" << endl; } int mini(int array[]) { int m = array[0]; for (int i = 0; i < n / 2; ++i) if (array[i] < m) m = array[i]; return m; } int maxi(int array[]) { int m = array[0]; for (int i = 0; i < n / 2; ++i) if (array[i] > m) m = array[i]; return m; } void conquer(int array[]) { int low[n /2], high[n / 2]; for (int i = 0; i < n / 2; i++) { if (array[i * 2] < array[i * 2 + 1]) { low[i] = array[i * 2]; high[i] = array[i * 2 + 1]; } else { high[i] = array[i * 2]; low[i] = array[i * 2 + 1]; } } cout << "mini: " << mini(low) << endl; cout << "maxi: " << maxi(high) << endl; } int main() { int tablica[n]; input(tablica); output(tablica); conquer(tablica); return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)