-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_length.cpp
More file actions
77 lines (69 loc) · 905 Bytes
/
get_length.cpp
File metadata and controls
77 lines (69 loc) · 905 Bytes
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include"header_file.h"
using namespace std;
int vec_max(vector<int> v)
{
int t;
t=0;
for(int i=1;i<v.size();i++)
{
if(v[t]<v[i])
{
t=i;
}
}
return v[t];
}
int get_max(vector<int> v)
{
vector<int> v1;
if(v.size()==1)
return 1;
else
{
if(v.size()==2)
{
if(v[1]>v[0])
return 2;
else
return 1;
}
else
{
for(int i=0;i<(v.size()-2);i++)
{
for(int j=i+1;j<(v.size()-1);j++)
{ int t;
t=1;
if(v[j]>v[i])
{
t++;
int k;
k=j+1;
for(;k<v.size();)
{
if((v[k]>v[j])&&(v[k]>v[k-1]))
{
t++;
k++;
}
}
if(k==v.size())
{
v1.push_back(t);
break;
} //v1.push_back(t);
}
}
}
vec_max(v1);
}
}
}
int main(void)
{
vector<int> v;
v.push_back(2);
v.push_back(1);
v.push_back(3);
cout<<get_max(v);
}