int postfix(node *ptr){
  if(ptr){
    postfix(ptr->leftnode);
    postfix(ptr->rightnode);
    printf("%c",prt->val);
  }
}
Exemplo n.º 2
0
Arquivo: isBst.c Projeto: iamon3/C_DFS
void postfix(tree*root)
{
    if(root)
    {
	postfix(root->left);
	postfix(root ->right);
	printf("%d\t",root -> data);
    }
}
Exemplo n.º 3
0
void postfix(treeNode *root)
{
    if(root)
    {
	postfix(root->lTree);
	postfix(root ->rTree);
	printf("%d\t",root -> data);
    }
}
void postfix(Pointer<T> pointer)
{
    if(pointer)
    {
        postfix(pointer->left_);
        postfix(pointer->right_);
        std::cout << pointer->val_ << " ";
    }
}
Exemplo n.º 5
0
void iDBF::Read(char *v, const int &len)  
{
	int ln= prefix();
	if (len < ln) buf[len]= '\x0';
	strcpy(v, buf);
	postfix();
}
Exemplo n.º 6
0
void makechar(chartype a)
{
  /* print out a character with appropriate prefix or postfix */
  prefix(a);
  putchar(cha[(long)a]);
  postfix(a);
}  /* makechar */
Exemplo n.º 7
0
void Verbose::generateEvalString(const CombinatorPtr& term1, const CombinatorPtr& term2, int evaluationDepth, bool cached)
{
    if (!isVerbose())
        return;

    QString apply = term1->toStringApply(term2, m_format);
    if (apply.isEmpty())
        return;

    Q_UNUSED(evaluationDepth);
    Q_UNUSED(cached);

    if (cached)
        m_cacheHits++;
    else
        m_cacheMisses++;

    if (evaluationDepth > m_depthAchieved)
        m_depthAchieved = evaluationDepth;

    if (apply.length() > m_longestEvalLine)
        m_longestEvalLine = apply.length();

    *m_stream << "  "
        << prefix()
        << apply
        << postfix()
#if 0
        << "\t" << "depth: " << evaluationDepth
        << ", " << (cached ? "cached: true" : "cached: false")
#endif
        << "\n";

    print();
}
Exemplo n.º 8
0
int64_t decode(void *buffer, size_t size, int64_t sum)
{
    unsigned int i;
    C(table_t) foobarcontainer;
    FooBar(vec_t) list;
    FooBar(table_t) foobar;
    Bar(struct_t) bar;
    Foo(struct_t) foo;

    foobarcontainer = C(as_root(buffer));
    sum += C(initialized(foobarcontainer));
    sum += StringLen(C(location(foobarcontainer)));
    sum += C(fruit(foobarcontainer));
    list = C(list(foobarcontainer));
    for (i = 0; i < FooBar(vec_len(list)); ++i) {
        foobar = FooBar(vec_at(list, i));
        sum += StringLen(FooBar(name(foobar)));
        sum += FooBar(postfix(foobar));
        sum += (int64_t)FooBar(rating(foobar));
        bar = FooBar(sibling(foobar));
        sum += (int64_t)Bar(ratio(bar));
        sum += Bar(size(bar));
        sum += Bar(time(bar));
        foo = Bar(parent(bar));
        sum += Foo(count(foo));
        sum += Foo(id(foo));
        sum += Foo(length(foo));
        sum += Foo(prefix(foo));
    }
    return sum + 2 * sum;
}
Exemplo n.º 9
0
char* iDBF::QuickReadString(int len)  
{
	int ln=prefix();
	if (len < ln) buf[len]= '\x0';
	postfix();
	return buf;
}
Exemplo n.º 10
0
bool AbstractAspect::readBasicAttributes(XmlStreamReader * reader)
{
	QString prefix(tr("XML read error: ","prefix for XML error messages"));
	QString postfix(tr(" (non-critical)", "postfix for XML error messages"));

	QXmlStreamAttributes attribs = reader->attributes();
	QString str;

	// read name
	str = attribs.value(reader->namespaceUri().toString(), "name").toString();
	if(str.isEmpty())
	{
		reader->raiseWarning(prefix+tr("aspect name missing or empty")+postfix);
	}
	setName(str);
	// read creation time
	str = attribs.value(reader->namespaceUri().toString(), "creation_time").toString();
	QDateTime creation_time = QDateTime::fromString(str, "yyyy-dd-MM hh:mm:ss:zzz");
	if(str.isEmpty() || !creation_time.isValid())
	{
		reader->raiseWarning(tr("Invalid creation time for '%1'. Using current time.").arg(name()));
		setCreationTime(QDateTime::currentDateTime());
	}
	else
		setCreationTime(creation_time);
	// read caption spec
	str = attribs.value(reader->namespaceUri().toString(), "caption_spec").toString();
	setCaptionSpec(str);

	return true;
}
Exemplo n.º 11
0
int main(void) {
    char input[80];
    printf("输入中序运算式:");
    scanf("%s", input);
    postfix(input);
    return 0;
}
Exemplo n.º 12
0
int main()
{
    char infix[15];
    int c=0;
    while(c<2)
    {
        printf("\n MAIN MENU \n");
        printf("1.ENTER EXPRESSION \n");
        printf("2.EXIT \n");
        printf("ENTER YOUR CHOICE \n");
        scanf("%d",&c);
        switch(c)
        {
            case 1: printf("ENTER THE EXPRESSION \n");
                    scanf("%s",infix);
                    postfix(infix);
                    break;
            case 2: c=3;

        }
    }


    return 0;

}
struct enode* postfix(struct enode* root)
{
	struct enode *temp = root;

	struct enode *temp1 = (struct enode*)calloc(1,sizeof(enode));
	struct enode *temp2 = NULL;
	if (temp)
	{
		postfix(temp->left);
		postfix(temp->right);
		temp2->data = temp->data;
		temp2->left = temp1;
		temp1 = temp2;
	}
	return temp1;
}
Exemplo n.º 14
0
int main()
{
    char a[] = "abc";
    char b[] = "";

    printf("%d \n", postfix(a, b));
    return 0;
}
Exemplo n.º 15
0
void iDBF::Read(long &v)  
{
	prefix();
	//v=atol(buf);
	long t;
	wxString::Format("%s", buf).ToCLong(&t);
	v=t;
	postfix();
}
Exemplo n.º 16
0
void iDBF::Read(double &v)  
{
	prefix();
	//v=atof(buf);
	double t;
	wxString::Format("%s", buf).ToCDouble(&t);
	v=t;
	postfix();
}
int solve_tree(struct enode *root){
	if (root==NULL)
    return -1;
	struct enode* exp=postfix(root);
	while (exp->left != NULL)
	{
		if ()
	}
	solve(exp);
}
Exemplo n.º 18
0
int main()
{
char infix[N],result[N];
int pos=0;
scanf("%s",infix);
printf("the original expression : %s\n",infix);
postfix(infix,result);
printf("postfix expression : %s\n",result);
return 0;
}
Exemplo n.º 19
0
int main()
{
    int totalNodesInTree, inFixArr[15],preFixArr[15],nodeToBeDeleted;
  treeNode *root = NULL;
  
  printf("\nEnter length of arr : ");
  scanf("%d",&totalNodesInTree);


  printf("\nEnter values of nodes in preorder\n");
  scanArr(preFixArr,totalNodesInTree);
  printArr(preFixArr,totalNodesInTree);


  printf("\nEnter values of nodes in inorder\n");
  scanArr(inFixArr,totalNodesInTree);
  printArr(inFixArr,totalNodesInTree);


  printf("\n\nPost Fix Order as shown :\n");
  root = toPostFix(inFixArr,preFixArr,0,totalNodesInTree-1,0);
  printf("\n");
  printf("after creating tree :- \n");
  printf("\nPrefix Notation\n");
  prefix(root);
  printf("\nInfix Notation\n");
  infix(root);
  printf("\nPostfix Notation\n");
  postfix(root);
  printf("\n");

/*  printf("Enter node to be deleted :- ");
  scanf("%d",&nodeToBeDeleted);
  root = deleteFromBst(root,nodeToBeDeleted);
*/
  ClearTree(&root);
  printf("After dispose :%d\n",root->data);
  postfix(root);
  printf("\n");

  return 0;
}
int main()
{
	char infix[MAX];
	char postr[MAX];
	printf ("Enter an infix expression \n");
	gets(infix);
	printf ("Infix  Expression  = %s \n", infix);
	postfix(infix, postr);
	printf ("Postfix Expression = %s", postr);
	getch();
}
Exemplo n.º 21
0
void main()
{
	int i,res;
	clrscr();
	printf("\n\n\n\t\t\tEnter the expression : ");
	scanf("%s",&expr);
	postfix();
  /*	res=eval();
	printf("\n\n\n\t\t\tResult = %d",res);    */
	getch();
}
Exemplo n.º 22
0
void grwrite(chartype c, long num, long *pos)
{
  int i;

  prefix(c);
  for (i = 1; i <= num; i++) {
    if ((*pos) >= leftedge && (*pos) - leftedge + 1 < screenwidth)
      putchar(cha[(long)c]);
    (*pos)++;
  }
  postfix(c);
}  /* grwrite */
Exemplo n.º 23
0
const char* YapClient::incrementPostfix()
{
    if (d->msgServerSocketPostfix) {
        free(d->msgServerSocketPostfix);
        d->msgServerSocketPostfix = 0;
    }

    if (::asprintf(&(d->msgServerSocketPostfix), "%d-%d", getpid(), s_socketNum++) <= 0)
        d->msgServerSocketPostfix = 0;

    return postfix();
}
Exemplo n.º 24
0
//*********Main Function**************
int main(){
    start=getNode();
    start->info=0;
    start->next=NULL;
    start->top=start;
    printf("\nEnter Postfix String: ");
    gets(input);
    postfix(input);
    printf("\nValue of expression %s\t=",input);
    display(start->top);
    printf("\n");
    
}//end main
Exemplo n.º 25
0
int main(int argc, const char * argv[]) {
	
	String str = initString;
	
	printf("\n\tThis program will compute the value of an postfix operation.\n\te.g. 135*+ = 1 + 3 * 5 = 16.\n\n\tEnter an valid postfix expression : ");
	scanf("%s", str);
	
	double result = postfix(str);
	
	printf("\n\t Result = %.3lf.\n\n", result);
	
	return 0;
}
Exemplo n.º 26
0
/** Called when asyn clients call pasynOctet->write().
  * This function performs actions for some parameters, including AttributesFile.
  * For all parameters it sets the value in the parameter library and calls any registered callbacks..
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Address of the string to write.
  * \param[in] nChars Number of characters to write.
  * \param[out] nActual Number of characters actually written. */
asynStatus NDPluginCircularBuff::writeOctet(asynUser *pasynUser, const char *value, size_t nChars, size_t *nActual)
{
  int addr=0;
  int function = pasynUser->reason;
  asynStatus status = asynSuccess;
  short postfixError;
  const char *functionName = "writeOctet";

  status = getAddress(pasynUser, &addr); if (status != asynSuccess) return(status);
  // Set the parameter in the parameter library.
  status = (asynStatus)setStringParam(addr, function, (char *)value);
  if (status != asynSuccess) return(status);

  if (function == NDCircBuffTriggerCalc){
    if (nChars > sizeof(triggerCalcInfix_)) nChars = sizeof(triggerCalcInfix_);
    // If the input string is empty then use a value of "0", otherwise there is an error
    if ((value == 0) || (strlen(value) == 0)) {
      strcpy(triggerCalcInfix_, DEFAULT_TRIGGER_CALC);
      setStringParam(NDCircBuffTriggerCalc, DEFAULT_TRIGGER_CALC);
    } else {
      strncpy(triggerCalcInfix_, value, nChars);
    }
    status = (asynStatus)postfix(triggerCalcInfix_, triggerCalcPostfix_, &postfixError);
    if (status) {
      asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
      "%s::%s error processing infix expression=%s, error=%s\n",
      driverName, functionName, triggerCalcInfix_, calcErrorStr(postfixError));
    }
  } 
  
  else if (function < FIRST_NDPLUGIN_CIRC_BUFF_PARAM) {
      /* If this parameter belongs to a base class call its method */
      status = NDPluginDriver::writeOctet(pasynUser, value, nChars, nActual);
  }

  // Do callbacks so higher layers see any changes
  callParamCallbacks(addr, addr);

  if (status){
    epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
                  "%s:%s: status=%d, function=%d, value=%s",
                  driverName, functionName, status, function, value);
  } else {
    asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
              "%s:%s: function=%d, value=%s\n",
              driverName, functionName, function, value);
  }
  *nActual = nChars;
  return status;
}
int main()
{struct stack s1,s2;
char infix[100],result[100];
printf("enter infix expression : ");
scanf("%s",infix);
create(&s1);
postfix(&s1,infix,result);
create(&s2);
struct tree *node=(struct tree*)malloc(sizeof(struct tree));
node=convert(result);
evaluate(&s2,node);
printf("value of the expression : %d",pop(&s2));
return 0;
}
Exemplo n.º 28
0
int main(void)
{
	string postfix("62+5*84/-");
	string postfix2("562*+9/");
	int result = 0;
	Stack stack1;

	result = evaluatePostfixExpression(postfix2, stack1);
	cout << result << endl;

	
	
	return 0;
}
Exemplo n.º 29
0
Expr const*
Parser::seq()
{
  Expr const* e = postfix();
  while (true) {
    if (match_if(semicolon_tok)) {
      if (ts_.eof())
        return e;
      e = on_seq(e, expr());
    }
    else
      break;
  }
  return e;
}
Exemplo n.º 30
0
const char *
contenttype(const char *filename)
{
    int i;
    char pf[BUFFER_SIZE];
    if (!postfix(filename, pf))
        return DEFAULT_CONTENT_TYPE;
    else {
        for (i = 0; i < CONTENT_TYPE_COUNT; ++i)
            if (strcmp(contentmap[i][0], pf) == 0)
                return contentmap[i][1];

        return DEFAULT_CONTENT_TYPE;
    }
}