-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumber.h
38 lines (33 loc) · 870 Bytes
/
number.h
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
#ifndef _NUMBER_H_
#define _NUMBER_H_
#include <stdio.h>
#include <stack.h>
namespace amo {
typedef enum {ADD, SUB, MUL, DIV, POW, FAC, L_P, R_P, EOE, ERROR} Operator;
class Number {
private:
static Number* instance;
Number();
~Number();
amo::Operator toOp(char c);
char orderOp(char op1, char op2);
bool isPrior(char op1, char op2);
bool isCal(char op);
int calculate(int arg, char op);
int calculate(int arg1, int arg2, char op);
public:
static Number& getInstance();
int getBinCount(int num);
long long power2(int n);
long long power(int base, int n);
int akermann(int m, int n);
int hailstone(int n);
int sum(std::vector<int>& vector);
int factory(int n);
int fibonacci(int n);
int fibonacci(int n, int& prev);
std::vector<char> rePolish(std::vector<char>& infix);
int evaluate(char* rpn);
};
};
#endif