Jump to content

aebstract

Members
  • Content Count

    1,105
  • Joined

  • Last visited

Community Reputation

0 Neutral

About aebstract

  • Rank
    Prolific Member

Profile Information

  • Gender
    Not Telling
  1. //$n=$_POST['t']; because you have // in front of it?
  2. It's not homework. It's just for a game online, for fun. It does give you a list of numbers in a row, and $n is the number of numbers that are in that row. I've solved the game through the code I have, but now I'm trying to shorten it as much as possible and use better methods to accomplish the task. It's just a fun learning thing, and can be done in any way you choose. The code I provided was the way I solved it, but I know there are other possibilities and better options which is why I'm looking for help on some of it. I don't really know why I would need $n, unless like you said to go thr
  3. <?php fscanf(STDIN,"%d",$n); $t = explode(" ", stream_get_line(STDIN, 256 + 1, "\n")); ?> This is how I get my original array, I don't have access to the source numbers beyond this. I'll play around with what you posted and see if I can figure something out.
  4. Because I don't know how to do a check to determine the correct option like that.
  5. An output of the array would look identical to what I showed as an example. Basically trying to find the closest value to 0 and if the closest value is the same positive and negative like -2 and 2, I need to output the positive.
  6. I have an array of numbers, something like: 1 > 5 2 > 10 3 > -2 4 > -6 5 > 3 I need to sort this array so that it is in numerical order IGNORING the negative signs. A correct ouput would be this order: -2 3 5 -6 10 Right now I am having to basically duplicate my array and then use str_replace to remove the - and then sort the list keeping my keys in tact with the values, that way I can go back and compare to my original array. I could use one array and do away with all of the extra if I knew a way to do this sort. Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.