Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:00:10+00:00 2026-06-06T20:00:10+00:00

Hello once again stackoverflow folks, this is really hard and it’s been torturing my

  • 0

Hello once again stackoverflow folks, this is really hard and it’s been torturing my brain. What I must do is, a multiplayer server-sided scoreboard. Basically 10 clients are connected into my server application, during this event everytime a player kill another player his kills are increased, each player connected to the server have a class pointer

class CUser
{
(...)
    public:
    unsigned m_uEventKills;
    unsigned m_uEventDeaths;
(...)
};

m_uEvenKills is increased everytime someone kills someone and ofc, m_uEventDeaths also increase for the dying player. Imagine player a,b,c,d,e,f each one of them have random kills (a,b,c,d… is a pointer to CUser) so:

a->m_uEventKills is 72
b->m_uEventKills is 13
c->m_uEventKills is 2
d->m_uEventKills is 44
e->m_uEventKills is 21
f->m_uEventKills is 33

and random values for deaths.

I have this:

int nMax[10];

void OrganizeMax()
{
    memset( &nMax, 0, sizeof( nMax ));
    (...)

Organize max must fill nMax, from 0 to 9 (10 top users) reading from all connected users (all of them own a pointer to CUser) ->m_uEventKills, and set to nMax[0] the one with most kills, to nMax[1] the second with most kills, to nMax[2] the thirt with most kills and so on…
Any briliant ideas of how to do this?

-Edit

I’ll be more simple, i have 10 vars.

int a,b,c,d,e,f,g,h,i,j;
a = 3;
b = 61;
c = 29;
d = 44;
e = 12;
f = 8;
g = 27;
h = 11;
i = 0;
j = 4;

I need to insert these vars into

int nHold[10];

in decreasing order, how do I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:00:13+00:00Added an answer on June 6, 2026 at 8:00 pm

    Instead of using a, b …f, I’d use a std::vector of CUser (BTW, I don’t like CUser as a class name):

    std::vector<CUser> users;
    

    If this is the only order you care about with respect to users, I’d define the ordering as part of the CUser class:

    class CUser { 
    
        // ...
        bool operator<(CUser const &other) const { 
             return m_uEventKills < other.m_uEventKills;
        }
    };
    

    Then when you need the users sorted into the correct order, you can do:

    std::sort(users.begin(), users.end());
    

    You will, however, probably need to add an ID number (or something like that) to the CUser class to keep track of which user is which, regardless of the order in which they happen to be arranged at the moment.

    Edit:

    To just get the values of ints in a…j into nHold in ascending order, you probably want to just insert them in their existing order, then sort:

    nHold[0] = a;
    nHold[1] = b;
    //...
    nHold[9] = j;
    
    std::sort(nHold, nHold+9);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello again stackoverflow... Once again I have a troublesome problem. I have a page
Hello again great knowledge masters of stackoverflow, once again the small coder apprentice tabaluga
Hello I have been having trouble with this for a while now. I have
Hello there once again... I came up with an strange idea but I have
Once again today with retyping.. In structure is pointer to function, in this function
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello! I'm not even sure if this is possible, but hopefully it is in
I'm once again in WPF binding hell :) I have a public class (
I'm trying to test this 'hello world' of python (with tornado) on ubuntu: import
Hey guys, I have a problem (again). This time I am trying to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.