Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 09 / task5.cpp
diff options
context:
space:
mode:
1 files changed, 21 insertions, 0 deletions
-rw-r--r--pract_SI/Pract. 09/task5.cpp21
diff --git a/pract_SI/Pract. 09/task5.cpp b/pract_SI/Pract. 09/task5.cpp
new file mode 100644
index 0000000..bd11733
--- /dev/null
+++ b/pract_SI/Pract. 09/task5.cpp
@@ -0,0 +1,21 @@
+//Way 1 - 3 parameters(array,size,position/index)
+bool Is_monotonically_increasing(const float* seq,int length,int position)
+{
+ if(position==length-1)
+ return true;
+ if(seq[position]>seq[position+1])
+ return false;
+ return Is_monotonically_increasing(seq,length,position+1);
+}
+
+//Way 2 - 2 parameters(array + size)
+bool Is_rising(const float* seq,int Size)
+{
+ if(Size<2)
+ return true;
+
+ if(*seq>*(seq+1)) ///Same as if(seq[0]>seq[1]) return false;
+ return false;
+
+ return Is_rising(++seq,Size-1);
+} \ No newline at end of file