Formula into C code...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daikide
    New Member
    • Aug 2007
    • 4

    Formula into C code...

    I need to translate this formula into C code, but I know very little programming. Can anyone help?

    http://mathworld.wolfr am.com/images/equations/MeanDeviation/equation1.gif
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Daikide
    I need to translate this formula into C code, but I know very little programming. Can anyone help?

    http://mathworld.wolfr am.com/images/equations/MeanDeviation/equation1.gif
    Read a C tutorial and pay special attention to the math functions available.

    Comment

    • arnaudk
      Contributor
      • Sep 2007
      • 425

      #3
      The moderators on this forum are particularly uncompromising when it comes to answering such questions directly even though it will probably take you a long time to write that code from zero knowledge but would take anyone with a little experience 30secs. It's a great idea to learn C or C++ but if it's auxiliary to your profession, then this might not be what you came here to be told.

      Anyway, I suggest you start by writing a "hello world" program. You can copy-paste the code for that from anywhere. Once you get that going, perhaps I'm allowed to tell you that the main ingredients you'll need will be an array to store your x_i values which can be an array in the C sense "int a = {1, 1, 2, 3, 5, 8};" or, even better, a vector. Then a you'll need a for() loop and the abs() absolute value function.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by arnaudk
        The moderators on this forum are particularly uncompromising when it comes to answering such questions directly even though it will probably take you a long time to write that code from zero knowledge but would take anyone with a little experience 30secs. It's a great idea to learn C or C++ but if it's auxiliary to your profession, then this might not be what you came here to be told.
        Schools, colleges and universities are tough cookies when they discover copied
        and pasted spoonfed solutions; they not only consider it cheating on behalf of the
        student but they also go after the source of the spoonfed solution. And ever so
        right they are. TSDN doesn't want to be a source of spoonfeeding nor cheating.

        Even more important: suppose you're a professional software developer and also
        suppose someone got away with the cheating, graduated and becomes your
        co-worker. You'd have a double task/job then: doing your own thing as well as
        cleaning up the mess created by your cheating co-worker.

        kind regards,

        Jos

        Comment

        • arnaudk
          Contributor
          • Sep 2007
          • 425

          #5
          I'm not a professional programmer but my experience gives me a different view about how to learn programming. Anyway, I won't mention it again. I think TSDN is a great site and I will abide by its rules.

          To at least make my message relevant to this thread, Daikide you should will always get a better response to your question if you demonstrate some attempt to solve it yourself. Post some code you're having difficulty with. If you don't know C or C++ at all and want to learn it, then you can ask for advice about that specifically.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            The OPs question has (almost) nothing to do with C or C++; we can only guess
            if the question has something to do with theoretical function theory, possibly with
            a finite domain D and a finite co-domain C, i.e.f(D) --> C. What are we supposed
            to answer? If f() is a surjection, injection of bijection? The cardinality of [D], |C|
            can tell a lot before digging into gory details.

            Just marking the particular c_i for a d_i can tell the rest.

            kind regards,

            Jos

            Comment

            Working...