int main(){ char a[1000],c[1000],b[1000]; scanf("%s",a); printf("\nGiven String : {%s}\n",a); replaceRange(a,c); replaceSq(c); replaceBraces(c); addPlus(c,b); printf("\nModified String : {%s}\n",b); return 0; }
GUIEquationEditor::GUIEquationEditor(QStringList SingelValues, QStringList Vectors ,QWidget *parent) : QDialog(parent), ui(new Ui::GUIEquationEditor) { ui->setupUi(this); ui->listWidget_Values->addItems(SingelValues); ui->listWidget_Vectors->addItems(Vectors); QObject::connect(ui->pushButton_plus, SIGNAL(clicked()), this, SLOT(addPlus())); QObject::connect(ui->pushButton_minus, SIGNAL(clicked()), this, SLOT(addMinus())); QObject::connect(ui->pushButton_multi, SIGNAL(clicked()), this, SLOT(addMulti())); QObject::connect(ui->pushButton_cos, SIGNAL(clicked()), this, SLOT(addCos())); QObject::connect(ui->pushButton_sin, SIGNAL(clicked()), this, SLOT(addSin())); QObject::connect(ui->pushButton_tan, SIGNAL(clicked()), this, SLOT(addTan())); QObject::connect(ui->pushButton_nov, SIGNAL(clicked()), this, SLOT(addNov())); QObject::connect(ui->pushButton_random, SIGNAL(clicked()), this, SLOT(addRandom())); QObject::connect(ui->pushButton_if, SIGNAL(clicked()), this, SLOT(addIf())); QObject::connect(ui->pushButton_values, SIGNAL(clicked()), this, SLOT(addValue())); QObject::connect(ui->pushButton_vectors, SIGNAL(clicked()), this, SLOT(addVector())); }
void infixToPostFix(const char *input,char *postfix){ // the strings are already assumed to be present // currently symbols ---> '-' range operator // '|' for union // '*' as usual // []() are essentially the same // permissible symbols are Alphabets,numerical,dot and everything else char a[1000],b[1000],c[1000]; copyString(input,a); printf("\nGiven Input :\n{%s}\n",a); replaceBraces(a); printf("\nAfter changing braces :\n{%s}\n",a); replaceRange(a,c); printf("\nAfter replacing the range operator :\n{%s}\n",c); addPlus(c,b); printf("\nAfter adding the extra +(s) :\n{%s}\n",b); /***********We will process on the string b********************/ stack S; queue Q; init_queue(&Q); init_stack(&S); int i=0; char stacktop; while(1){ if(b[i]=='\0'){ // break the while loop and transfer everything stack to queue break; } switch(b[i]){ case '+':{ while(1){ if(isStackEmpty(&S)==1){ break; } stacktop=stack_top(&S); if(stacktop=='+'||stacktop=='|'||stacktop=='*'){ stack_pop(&S); enqueue(&Q,stacktop); }else{ break; } } stack_push(&S,b[i]); break; } case '|':{ while(1){ if(isStackEmpty(&S)==1){ break; } stacktop=stack_top(&S); if(stacktop=='|'||stacktop=='*'){ stack_pop(&S); enqueue(&Q,stacktop); }else{ break; } } stack_push(&S,b[i]); break; } case '*':{ while(1){ if(isStackEmpty(&S)==1){ break; } stacktop=stack_top(&S); if(stacktop=='*'){ stack_pop(&S); enqueue(&Q,stacktop); }else{ break; } } stack_push(&S,b[i]); break; } case '(':{ stack_push(&S,b[i]); break; } case ')':{ while(1){ if(isStackEmpty(&S)==1){ printf("\nParenthesis Missmatch !!\n"); return; } stacktop=stack_top(&S); if(stacktop=='('){ stack_pop(&S); break; }else{ stack_pop(&S); enqueue(&Q,stacktop); // break; } } break; } default:{ // otherwise the character is taken as a valid symbol enqueue(&Q,b[i]); } } i++; } while(1){ if(isStackEmpty(&S)==1){ break; } stacktop=stack_top(&S); if(stacktop=='('||stacktop==')'){ printf("\nParenthesis Missmatch!!!\n"); return; } enqueue(&Q,stacktop); stack_pop(&S); } printf("\nPostfix created successfully\n"); queueToString(&Q,postfix); printf("\nPostfix\n :{%s}\n",postfix); return; }