summaryrefslogtreecommitdiff
path: root/arrayMinMax.cc
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-01-20 19:46:47 +0100
committerGitHub <noreply@github.com>2017-01-20 19:46:47 +0100
commitab8183f7a2036f7cb4714081063bb80a84757df4 (patch)
tree64d3eb3c66cbe20432f99218c56b413f98b3063b /arrayMinMax.cc
parentaf87fe2015e4634ed48ced8c56a702a0742f6ef9 (diff)
Add files via upload
Diffstat (limited to 'arrayMinMax.cc')
-rw-r--r--arrayMinMax.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/arrayMinMax.cc b/arrayMinMax.cc
new file mode 100644
index 0000000..be36903
--- /dev/null
+++ b/arrayMinMax.cc
@@ -0,0 +1,35 @@
+#include <iostream>
+
+using namespace std;
+
+int main(void)
+{
+ int a[] = {5,14,9,8,10,65,32,1,6,78};
+ int tot = sizeof a / sizeof(int);
+ int t, i, j, minore = a[0], maggiore = a[tot-1];
+
+ for(i = 0; i < tot; i++)
+ {
+ for(j = 0; j < tot-1; j++)
+ {
+ if(a[j] > a[j+1]){
+ t = a[j+1];
+ a[j+1] = a[j];
+ a[j] = t;
+ }
+ }
+ }
+
+ //for(i = 0; i < tot; i++) cout << a[i] << endl;
+
+ /*for(int i = 0; i < tot; i++)
+ {
+ if(a[i] < minore) minore = a[i];
+ else if(a[i] > maggiore) maggiore = a[i];
+ }*/
+
+ cout << minore << endl;
+ cout << maggiore << endl;
+
+ return 0;
+}