- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
double end_line( char data[0][200]){
double x = 0 , y = 0, sum = 0,ml = 0 ;
char *point = strtok( &data[1][0] , " " );
while( point != '\0' ){
if(isdigit( *point ) ){
ml = atof( (char *) point ) ;
push_stack_2( &topPTR_2,ml);
}
else if ( isOperator ( *point ) == 1 ){
y = pop_2(&topPTR_2);
x = pop_2(&topPTR_2);
if( *point == '^' ){
sum = pow(x, y) ;
push_stack_2( &topPTR_2, sum );
}
if( *point == '*' ){
push_stack_2(&topPTR_2, x * y );
}
if( *point == '+' ){
push_stack_2(&topPTR_2, x + y );
}
if( *point == '/' ){
push_stack_2(&topPTR_2, x / y );
}
if( *point == '-' ){
push_stack_2(&topPTR_2, x - y );
}
}
point = strtok(NULL , " " ) ;
return pop_2(&topPTR_2);
}
int in_line(char data[][200] , int lng ){
double x = 0 , y = 0, sum = 0 ;
int j = 0 , k = 0 , d = 0;
data[0][lng ] = ')';
push_stack(&topPTR, '(');
for (k = 0; check_stack((void *) &topPTR) != 1 ; k++) {
if ( isdigit(data[0][k]) || data[0][k] == '.' ) {
data[1][j++] = data[0][k];
}
if (data[0][k] == '(') {
push_stack(&topPTR, infix[0][k]);
}
if (isOperator(data[0][k]) == 1) {
data[1][j++] = ' ';
for (; precedence(topPTR->alpha, data[0][k]) != -1 ; ) {
data[1][j++] = pop(&topPTR);
data[1][j++] = ' ';
}
push_stack(&topPTR, data[0][k]);
push_stack(&topPTR, ' ' );
}
if (data[0][k] == ')') {
d = pop(&topPTR);
for (; d != '(' ; d = pop(&topPTR)) {
data[1][j++] = d;
}
}
else if (isalpha(data[0][k] ) ) {
puts ("error");
return 0;
}
}
return 1;
}