• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Results 1 to 10 of 10
    1. #1
      Newbie
      Learning to hack games!
       
      Trolling
       
      voila's Avatar
      Join Date
      Nov 2013
      Posts
      9
      Thanks (-->)
      2
      Thanks (<--)
      1

      Sorting arrays first min and max and then in a ordered list from user input.

      Silent VPN
      Hey, i am learning c++ at the moment, i have quite a bit of testing projects.
      So i made a array first min and max sorting and then in a ordered list.
      Maybe if someone could tell me if i could do something better, and why i should do it that way i would appreciate it...
      code:

      *Note:Please use code tags*

      #include <iostream>
      #include <string>
      int MAX,MIN = 0;
      using namespace std;
      int main()
      {
      string username[10];
      int Sort[10];
      int pancakes[10];
      int a, b;




      for(int x=0; x<=9; x++) // for loop to ask 10 questions ask for name and how many pancakes they ate,
      {
      cout << "Tell me the name of person " << x <<endl;
      cin >> username[x];
      cout<<"how much pancakes did " << username[x] << " eat\n" << endl;
      cin >> pancakes[x];


      if(pancakes[MAX] < pancakes[x])MAX = x;
      if(pancakes[MIN] > pancakes[x])MIN = x;// checking the max and min values on eaten pancakes
      }


      cout << "The person that ate most pancakes is Person " << username[MAX] << " that ate: " << pancakes[MAX] << " pancakes\n" << "The person that ate least pancakes is Person " << username[MIN] << " that ate: " << pancakes[MIN] << " pancakes\n" << "Press any key to get the ordered list from least to most" << endl;//printing who ate most and least
      system("pause");


      for(b=0;b<=9;b++)//set array sort to a value so we can use it later
      {
      Sort[b]=b;
      }


      for(b=0; b<=8; b++)
      {
      for(a=b+1;a<=9;a++)
      {
      int temp;
      if(pancakes[Sort[b]] > pancakes[Sort[a]])// if variable b value is greater than var a


      {
      temp = Sort[b];//assign temp to value of whatever b is
      Sort[b] = Sort[a];// taking the pancake a and puting it into pancake b
      Sort[a] = temp;// putting the value of num a as the temp. so this is where the loop becomes usefull.
      }
      }
      }
      cout << "ordered list " << endl;
      for(b=0;b<=9;b++)
      {
      cout << "Name : "<< username[Sort[b]] << " ate "<< pancakes[Sort[b]] << " pancakes" << endl;


      }
      system("pause");
      }




      Its working no errors but just want to see if i am heading in the right path! if my comments are right etc.

    2. #2
      Hacker
      Turning to page 394...
       
      Coding
       
      Liduen's Avatar
      Join Date
      May 2013
      Location
      Germany
      Posts
      713
      Thanks (-->)
      161
      Thanks (<--)
      226
      Well, I'm still not good at programming, but I would say this code is well written.
      But I could not really figure out how these two for{} loops work. But this is my problem.

      This example really helps when calculating which one of the enemies is closest to you and at who to aim at, when the first enemy died.
      I'll need that for my aimbot ^^
      My contributions
      UrbanTerror | OpenGL - ModelLogger | Polymorphic junk code | Tutorial/Article Collection
      Admiring technological singularity

    3. #3
      Newbie
      Learning to hack games!
       
      Trolling
       
      voila's Avatar
      Join Date
      Nov 2013
      Posts
      9
      Thanks (-->)
      2
      Thanks (<--)
      1
      Quote Originally Posted by Liduen View Post
      Well, I'm still not good at programming, but I would say this code is well written.
      But I could not really figure out how these two for{} loops work. But this is my problem.

      This example really helps when calculating which one of the enemies is closest to you and at who to aim at, when the first enemy died.
      I'll need that for my aimbot ^^
      Thanks, it took time for me to understand how the for loop works but i would say once you sit and maybe try 1 hour to test whats working and whats not it will make sence.
      caues i was trying first to do an if statement 10 times, which isnt good and not really flexible.
      So i remembered the index ordering (if its called that) its some ordering method done by a guy long time ago and i managed to write it after some hour.
      Might sound redicoulous that im trying some hour on some number sorterer but i learn stuff the best that way!
      ty for ur feedback

    4. #4
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      492
      Bubble sort isn't the fastest method afaik.
      Sorting arrays first min and max and then in a ordered list from user input.

    5. Thanks xPaay thanked for this post
    6. #5
      Hacker
      Learning to hack games!
       
      Pawning
       
      Fleep's Avatar
      Join Date
      May 2012
      Posts
      626
      Thanks (-->)
      208
      Thanks (<--)
      743
      Quote Originally Posted by c5 View Post
      Bubble sort isn't the fastest method afaik.
      Yh I would recommend either the quick sort or heap sort for speed.

      Bubble is pretty much as slow as it gets.

      Fleep

    7. #6
      Coder
      Creating UE3 x86/x64 tut
       
      Coding
       
      TastyHorror's Avatar
      Join Date
      Oct 2012
      Location
      Canada
      Posts
      184
      Thanks (-->)
      54
      Thanks (<--)
      82
      People actually use bubble sort? What is this madness.

    8. #7
      Newbie
      Learning to hack games!
       
      Trolling
       
      voila's Avatar
      Join Date
      Nov 2013
      Posts
      9
      Thanks (-->)
      2
      Thanks (<--)
      1
      Quote Originally Posted by Fleep View Post
      Yh I would recommend either the quick sort or heap sort for speed.

      Bubble is pretty much as slow as it gets.

      Fleep
      Oh so this is "bubble sort"
      thanks for the feedback, i thought this was "index" sorting.
      As i remember watching some tutorial LONG time ago on java, took the method from there.
      note that i am learning c++ and i created this without watching any tutorial..
      Apprecheate your feedback
      Can you tell me the logic behind quick sort? like i dont want any code or something..
      But if i google "quick sort" i will get the code, so thanks if u wanna tell me.

    9. Thanks Fleep thanked for this post
    10. #8
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      492
      Quote Originally Posted by TastyHorror View Post
      People actually use bubble sort? What is this madness.
      It's the easiest way to sort small amount of items in a simple order?
      Sorting arrays first min and max and then in a ordered list from user input.

    11. Thanks voila thanked for this post
    12. #9
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      xPaay's Avatar
      Join Date
      Jun 2013
      Posts
      1
      Thanks (-->)
      1
      Thanks (<--)
      0
      There's no best sorting algorithm. Every algorithm is better then others on some cases. This site has some good animations with the most used sorting algorithm.

      https://www.sorting-algorithms.com/

      Btw I've got a schoolwork where I needed to get the time to sort a 1 million+ vector in three different cases and with at least 4 sorting algorithm. In my case bubblesort was the worse on most cases, but in one specific test, quicksort was slower then bubble.

    13. #10
      RTFM
      Shootin Pool!
       
      Coding
       
      Syperus's Avatar
      Join Date
      Oct 2012
      Location
      127.0.0.1
      Posts
      436
      Thanks (-->)
      101
      Thanks (<--)
      131
      Silent VPN
      I would also change system("pause") to std::cin.get() so it can be used on multiple OS's. Irregardless of what method you use it was a good learning exercise I'm sure.
      Blacks Ops Zombies, BioShock Infinite Array of Bytes
      "People say I'm a bad influence. I say the world's already fucked, I'm just adding to it" -Eminem

    14. Thanks voila thanked for this post

    Similar Game Hacker Threads

    1. [Help] [Java] Get user input and submit it into a website.
      By maxownage01 in forum Misc Coding
      Replies: 6
      Last Post: 06-23-2016, 10:37 AM
    2. [Help] Clearing the user input
      By tvojama in forum C/C++
      Replies: 5
      Last Post: 02-29-2016, 01:06 AM
    3. [Help] Help with Arrays
      By TBA in forum C/C++
      Replies: 13
      Last Post: 02-29-2016, 12:59 AM
    4. [Off Topic] Ban the user above you!
      By Syntax Error in forum Off Topic
      Replies: 23
      Last Post: 05-06-2015, 03:17 AM
    5. Arrays in a nutshell!!
      By konsowa in forum C#
      Replies: 4
      Last Post: 05-27-2012, 03:49 PM

    Tags for this Thread