-
Notifications
You must be signed in to change notification settings - Fork 0
/
parts.hpp
51 lines (43 loc) · 1.15 KB
/
parts.hpp
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
#include <iostream>
#include <stack>
typedef long long elementtype;
typedef std::stack<elementtype> MyStack;
bool FindElement(MyStack sample ,elementtype target){
while(!sample.empty()){
if(sample.top()== target)
return true;
sample.pop();
}
return false;
}
void ReverseStack(MyStack &sample){
MyStack tmp;
while(!sample.empty()){
tmp.push(sample.top());
sample.pop();
}
sample = tmp;
}
/* PROGRAM PARTS */
void GetNumOfEachWH_Sacks(MyStack &workhouse_stacks,elementtype Num_of_Workhouse){
elementtype input;
for(int counter = 0; counter < Num_of_Workhouse ; counter++){
std::cin >> input;
workhouse_stacks.push(input);
}
}
void ReturnAllAsItwas(MyStack &tmp_stack,MyStack &workhouse_stacks){
while(!tmp_stack.empty()){
workhouse_stacks.push(tmp_stack.top());
tmp_stack.pop();
}
}
void maxChecking(elementtype &sum,elementtype &max_value){
if(sum != 0 )
if(sum > max_value)
max_value = sum;
}
void GoNext(MyStack &tmp_stack,MyStack &workhouse_stacks){
tmp_stack.push(workhouse_stacks.top());
workhouse_stacks.pop();
}