Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Read file, write to array, find min and max

Read file, write to array, find min and max

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelp
20 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D dr eu

    About homework you have right ! About teacher ... Who nows ? Any way could you help ?

    R Offline
    R Offline
    rocky_pulley
    wrote on last edited by
    #11

    I can't really do your homework for you, you won't learn anything that way. Besides, you are 90% there, just take the time and figure it out, you're almost done. -- Rocky Dean Pulley

    D 1 Reply Last reply
    0
    • R rocky_pulley

      I can't really do your homework for you, you won't learn anything that way. Besides, you are 90% there, just take the time and figure it out, you're almost done. -- Rocky Dean Pulley

      D Offline
      D Offline
      dr eu
      wrote on last edited by
      #12

      Yes, from that almost i am gona crazy. The result is O.K. (for all numbers in file). Help me please with 100, 200, ... elements in array !!!

      R 1 Reply Last reply
      0
      • D dr eu

        Yes, but how can i write big10489=biggest(&table[1048800], 100); ? This will take a lot of my time. And i don?t now, if file is so long?

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #13

        dr.eu wrote: Yes, but how can i write big10489=biggest(&table[1048800], 100); ? Exactly like that. This assumes that you have read at least 1,048,900 numbers from the file.


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        D 1 Reply Last reply
        0
        • D dr eu

          Yes, from that almost i am gona crazy. The result is O.K. (for all numbers in file). Help me please with 100, 200, ... elements in array !!!

          R Offline
          R Offline
          rocky_pulley
          wrote on last edited by
          #14

          just use the same array, once you hit a number where (current_number % 100 == 0) then do your biggest/smallest check and reset current_number to 0, keep going on after that and it will just reuse your 100 item array. -- Rocky Dean Pulley

          D 1 Reply Last reply
          0
          • D David Crow

            dr.eu wrote: Yes, but how can i write big10489=biggest(&table[1048800], 100); ? Exactly like that. This assumes that you have read at least 1,048,900 numbers from the file.


            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            D Offline
            D Offline
            dr eu
            wrote on last edited by
            #15

            In that case, i have to import another counter j: int j; bigj=biggest(&table[j], 100); Is right so?

            1 Reply Last reply
            0
            • R rocky_pulley

              just use the same array, once you hit a number where (current_number % 100 == 0) then do your biggest/smallest check and reset current_number to 0, keep going on after that and it will just reuse your 100 item array. -- Rocky Dean Pulley

              D Offline
              D Offline
              dr eu
              wrote on last edited by
              #16

              I done so: while (fscanf(in,"%f",&element) != EOF) { table[num_elements] = element; current_number=element; current_number%100==0; num_elements++; } but steel dont work propertly.

              D 1 Reply Last reply
              0
              • D dr eu

                I done so: while (fscanf(in,"%f",&element) != EOF) { table[num_elements] = element; current_number=element; current_number%100==0; num_elements++; } but steel dont work propertly.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #17

                How about:

                while (...)
                {
                table[num_elements] = element;
                num_elements++;
                if ((num_elements % 100) == 0)
                {
                biggest(...);
                smallest(...);
                num_elements = 0;
                }
                }


                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                D 1 Reply Last reply
                0
                • D David Crow

                  How about:

                  while (...)
                  {
                  table[num_elements] = element;
                  num_elements++;
                  if ((num_elements % 100) == 0)
                  {
                  biggest(...);
                  smallest(...);
                  num_elements = 0;
                  }
                  }


                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  D Offline
                  D Offline
                  dr eu
                  wrote on last edited by
                  #18

                  I try, but compiler return erors: too few arguments to function `float * biggest(float *, int)' at this point in file too few arguments to function `float * smallest(float *, int)' at this point in file

                  R 1 Reply Last reply
                  0
                  • D dr eu

                    I try, but compiler return erors: too few arguments to function `float * biggest(float *, int)' at this point in file too few arguments to function `float * smallest(float *, int)' at this point in file

                    R Offline
                    R Offline
                    rocky_pulley
                    wrote on last edited by
                    #19

                    I don't mean to sound mean but you should really be able to figure that one out. -- Rocky Dean Pulley

                    D 1 Reply Last reply
                    0
                    • R rocky_pulley

                      I don't mean to sound mean but you should really be able to figure that one out. -- Rocky Dean Pulley

                      D Offline
                      D Offline
                      dr eu
                      wrote on last edited by
                      #20

                      O.K., Thank you anyway for yours great help and good understanding. I'll try to do it well alone, but i'm not sure in access. Thanks again and goodbay !

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups