i have a simple program to sort a amount of interigers that the user enteres and cannot use subscripts and i just am lost how to do this i just need a simple idea how. i can program and i'm probably over thinking this.
thank you.
josh
ok that went over my head. i just need the teacher to enter a unknown number of interger and sort them and find the highest and lowest and print the results. I can't use subscripts with is throwing me for a loop (pun intended) i have done this with sub scripts but not without subscrupts.
Are you allowed to use the STL containers or not?
By the way, you mean you can't use arrays right?
Actually... PanGalactic is right, it's irrelevant.
Just slap the code to get a number into a for loop. Keep track of the lowest and highest numbers. If this new number is lower than the current lowest or higher than the current highest (or possibly both if it's your first number) then change the lowest or highest number to the current number. Keep on going around until the teacher inputs a special value to quit the loop.
Not going to give you the code for that though, it's not too complicated to code yourself.
Wait... so you are supposed to use an array but you aren't supposed to use the subscript operator? O_o That will be ugly and inefficient...
OK, well I haven't used pointers in a while, but you probably know how they work with arrays; just increment the pointer's address through the array instead of the subscripting. My question is, how are you supposed to create the array if you don't know how many elements are in it? Does the user input that number at the beginning? (in that case you can do dynamic allocation)