-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.h
More file actions
111 lines (96 loc) · 2.51 KB
/
function.h
File metadata and controls
111 lines (96 loc) · 2.51 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef FUNCTION_H
#define FUNCTION_H
#include <stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MAX 1000000
#define start 0
#define digit 1
#define operator 2
#define space 3
#define error 4
#define left 5
#define right 6
typedef struct node {
int data;
struct node* prev;
struct node* next;
}node;
typedef node* list;
typedef struct token {
int type; // type takes values DIGIT/OPERATOR/STOP/ERROR/START
union value{
list N;
char op;
}value;
}token;
void init(list *l);
void append(list *l, int d);
void traverse(list l);
void ctraverse(list l);
void reverse(list *l);
void pop_First(list *l);
void pop_Last(list *l);
void Remove(list *l, int d);
int len(list l);
int search(list l, int d);
void insert_beg(list *l, int d);
void insert_At(list *l, int i, int d);
void destroy(list *l);
list readline();
int date();
list get_number();
list remove_zeros(list N1);
int compare(list N1, list N2);
list add_number(list N1, list N2);
list subtract_number(list N1, list N2);
list mul_number(list N1, list N2);
list subfloordivision_number(list N1, list N2);
list submodulodivision_number(list N1, list N2);
list floordivision_number(list N1, list N2);
list modulodivision_number(list N1, list N2);
list subpower(list N1, list N2);
list power(list N1, list N2);
list exponent(list N1);
list fact(list N);
list sqroot(list N1);
float sine(list N);
float cosine(list N);
float ln(list N);
////////////////////////////////
int fact_int(int n); //used in sine
int precedence(char c);
list applyOp(list a, list b, char c);
///////////using single linked list////////////////
//////////////operator stack////////////////
typedef struct oprator {
char opr;
struct oprator* next;
}opratornode;
typedef opratornode* oprator;
void init_oprator(oprator *s);
int isEmpty_oprator(oprator s);
void push_oprator(oprator *s, char op);
char pop_oprator(oprator *s);
char peek_oprator(oprator s);
void print_oprator(oprator s);
void empty_oprator(oprator *s);
//////////////operand stack///////////////////
typedef struct oprnd{
list num; //double linked list
struct oprnd* next;
}oprndnode;
typedef oprndnode* oprnd;
void init_oprnd(oprnd *s);
int isEmpty_oprnd(oprnd s);
void push_oprnd(oprnd *s, list num);
list pop_oprnd(oprnd *s);
list peek_oprnd(oprnd s);
void print_oprnd(oprnd s);
void empty_oprnd(oprnd *s);
token gettoken(list E, oprnd *s1, oprator *s2);
list infix(list L);
#endif