Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
C++ functions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jacques Rioux  
View profile  
 More options May 25 1993, 7:01 pm
Newsgroups: comp.lang.c++
From: jrio...@act.ulaval.ca (Jacques Rioux)
Date: Tue, 25 May 1993 22:55:08 GMT
Local: Tues, May 25 1993 6:55 pm
Subject: C++ functions
Hi everyone,

 I'm writing a math program and I have a big problem.  The program needs for
input a math function like  3x+2.  But if I read it with the scanf, it
thinks that it is a string and not a function.  I would like be evaluated
this function for different values of x.  Is it possible to convert that
string to a mathematical function.

Thank you

 Jacques Rioux


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul J Lucas  
View profile  
 More options May 26 1993, 9:41 am
Newsgroups: comp.lang.c++
From: gru...@cbnewse.cb.att.com (Paul J Lucas)
Date: Wed, 26 May 1993 13:19:52 GMT
Local: Wed, May 26 1993 9:19 am
Subject: Re: C++ functions
From article <jrioux1...@act.ulaval.ca>, by jrio...@act.ulaval.ca (Jacques Rioux):

>  I'm writing a math program and I have a big problem.  The program needs for
> input a math function like  3x+2.  But if I read it with the scanf, it
> thinks that it is a string and not a function.  I would like be evaluated
> this function for different values of x.  Is it possible to convert that
> string to a mathematical function.

        Does the word 'parser' mean anything to you?  Ever heard of
        'yacc'?  If you have, then you know what you have to do; if you
        haven't, well...
--
        - Paul J. Lucas
          AT&T Bell Laboratories
          Naperville, IL

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jose A. Espinosa Villanueva  
View profile  
 More options May 26 1993, 11:36 am
Newsgroups: comp.lang.c++
From: espin...@dia.fi.upm.es (Jose A. Espinosa Villanueva)
Date: 26 May 93 15:30:40 +0200
Local: Wed, May 26 1993 9:30 am
Subject: Re: C++ functions
In article 2...@act.ulaval.ca, jrio...@act.ulaval.ca (Jacques Rioux) writes:

> I'm writing a math program and I have a big problem.  The program needs for
>input a math function like  3x+2.  But if I read it with the scanf, it
>thinks that it is a string and not a function.  I would like be evaluated
>this function for different values of x.  Is it possible to convert that
>string to a mathematical function.

        I don't know if you have experience programming enough. The input
for a program (using scanf or not) can be only strings or numbers. If you
want convert the input string to a function, you should build lots of
procedures and data structures to handle it.
        For example: you can convert the "formula" string into a binary tree
and then build functions to evaluate it.

                3 x + 2

                        root
                        (+)
                        /  \
                       (*)  2
                       / \
                      3   x
struct tree
{       typenode node;
        struct tree *left,*right;

};

int evaluate (struct tree t)
{
        if (number(t.node))
                return (number (t.node));
        return (operation (t.node,evaluate(t->left),evaluate(t->right)));

}

number :: function that return the value of numerical node.
operation :: function that make the operation t.node with our parameters.

GREETINGS FROM SPAIN
(SALUDOS)

=========================================================================== ===
   _/_/_/_/_/_/_/_/_/_/   | |               Jose Antonio Espinosa
        _/    _/          | |       Laboratorio de Inteligencia Artificial
       _/_/_/_/_/_/       | |              Facultad de Informatica
 _/   _/    _/            | |         Universidad Politecnica de Madrid
  _/_/     _/_/_/_/       | |           espin...@alcala.dia.fi.upm.es
=========================================================================== ===


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
BGAA  
View profile  
 More options May 31 1993, 12:32 pm
Newsgroups: comp.lang.c++
From: BGAA <B...@MUSICB.MCGILL.CA>
Date: Wed, 26 May 1993 06:01:31 GMT
Local: Wed, May 26 1993 2:01 am
Subject: RE: C++ functions
In article <jrioux1...@act.ulaval.ca> jrio...@act.ulaval.ca (Jacques Rioux) writes:
>Hi everyone,

> I'm writing a math program and I have a big problem.  The program needs for
>input a math function like  3x+2.  But if I read it with the scanf, it
>thinks that it is a string and not a function.  I would like be evaluated
>this function for different values of x.  Is it possible to convert that
>string to a mathematical function.

You should be able to use the atoi function in standard c library to
convert ASCII to integer.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »