-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathcode_1.cpp
40 lines (37 loc) · 870 Bytes
/
code_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// code_1.cpp
// Algorithm
//
// Created by Mohd Shoaib Rayeen on 23/11/18.
// Copyright © 2018 Shoaib Rayeen. All rights reserved.
//
#include <iostream>
#include <vector>
using namespace std;
int getCountIncreasingSubArrays(vector<int>arr){
int n = int(arr.size());
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (arr[j] > arr[j-1]) {
count++;
}
else {
break;
}
}
}
return count;
}
int main() {
int n;
cout << "\nEnter Size of Array\t:\t";
cin >> n;
vector<int> array(n);
cout << "\nEnter Array Element\n";
for (int i = 0; i < n; i++ ) {
cin >> array[i];
}
cout << "\nNumber of Strictly Subarrays\t:\t" << getCountIncreasingSubArrays(array) << "\n";
return 0;
}