Skip to content

Instantly share code, notes, and snippets.

@shmutalov
Created July 24, 2019 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmutalov/ff19b73d16ffb3f63e2c794bd0139cd8 to your computer and use it in GitHub Desktop.
Save shmutalov/ff19b73d16ffb3f63e2c794bd0139cd8 to your computer and use it in GitHub Desktop.
while(1)
{
char token[100];
int index = 0;
bool flag;
if(Worker2())
break;
for(i = separator; stroka[i] != '\0'; i++)
{
flag = false;
if(stroka[i]=='(' || stroka[i]==')' || stroka[i]=='+'
|| stroka[i]=='-' || stroka[i]=='*' || stroka[i]=='/'
|| stroka[i]=='^' || stroka[i]=='!' || stroka[i]=='=')
{
if(stroka[i]==')')
{
if(Worker1())
{
break;
}
}
else
{
if(stroka[i]=='(')
{
st_ch.push(stroka[i]);
}
else if(st_ch.top() != '0')
{
if (get_oper(stroka[i]) <= get_oper(st_ch.top()))
{
while(get_oper(stroka[i]) <= get_oper(st_ch.top()))
{
que.q(st_ch.pop());
}
}
st_ch.push(stroka[i]);
}
if(st_ch.top() == '0') st_ch.push(stroka[i]);
}
}
else
{
if (isdigit(stroka[i]) || stroka[i]=='.')
{
while(isdigit(stroka[i]) || stroka[i]=='.')
{
token[index++] = stroka[i++];
}
token[index] = 0;
index = 0;
que.q(atof(token));
flag = true;
}
bool fl = true;
if (isalpha(stroka[i]))
{
while(isalpha(stroka[i]) || isdigit(stroka[i])
|| stroka[i]=='_')
{
token[index++] = stroka[i++];
if(stroka[i] == '=')
{
token[index] = '~';
token[index + 1] = '\0';
fl = false;
break;
}
}
if(fl == true) token[index] = '\0';
index = 0;
que.q(token);
flag = true;
}
if(flag) i--;
if(stroka[i] == ':')
{
separator = i + 1;
if(stroka[separator])
{
counter = 0;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment