-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaximum.cpp
More file actions
67 lines (35 loc) · 714 Bytes
/
maximum.cpp
File metadata and controls
67 lines (35 loc) · 714 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
#include<iostream>
using namespace std;
#define max 5
int top=-1;
int a[max];
void push(int n)
{
a[++top]=n;
}
void pop(int *n)
{
*n=a[top];//Returns the value that is to be deleted
top--;
}
int main()
{
char n[5]; int pos,m,si,i,j,k,temp;
cin>>n>>k;
for(i=0;n[i]!='\0';i++)
push(n[i]-48);
si=i;
m=a[0];
for(i=0;i<si-1;i++)
{
if(a[i]>=m)
{
pos=i;}
}
if(si-k == 1) cout<< a[si-1];
else
for(i=pos;i<pos+(si-k);i++)
{
cout<<a[i];
}
}