-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRecord_Breaking_Days.cpp
53 lines (47 loc) · 1.32 KB
/
Record_Breaking_Days.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
41
42
43
44
45
46
47
48
49
50
51
52
53
// WAP To Calculate Record-Breaking Days As Per User's Condition.
// Problem Statement:
// Isyana is given the number of visitors at her local theme park on N consecutive days.
// The number of visitors on the i-th day is V. A day is record breaking if it satisfies both
// of the following conditions:
// 1. The number of visitors on the day is strictly larger than the number of
// visitors on each of the previous days.
// 2. Either it is the last day, or the number of visitors on the day is strictly
// larger than the number of visitors on the following day.
// Note that the very first day could be a record breaking day!
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
int n;
cout<<"Enter The Numbers of Visitors:-";
cin>>n;
int A[n];
for(int i=0;i<n;i++)
{
cin>>A[i];
}
int Max=A[0];
int i=1;
int days=1; //Note that the very first day could be a record breaking day!
while(i<n)
{
if(i!=n)
{
if(Max<A[i] && A[i+1]<A[i])
{
days++;
}
}
else {
if(Max<A[i])
{
days++;
}}
Max=max(Max,A[i]);
i++;
}
cout<<"Total Number Of Record Breaking Days:-"<<days;
return 0;
}