Thread: The last three teams

  1. #1
    Registered User
    Join Date
    Oct 2011
    Location
    Karnobat, Bulgaria
    Posts
    2

    The last three teams

    Hello friends .
    I have a problem with a C + + program.
    I have the structure and array. Structure is:
    Code:
    struct otbor { 
    char imenaotbora[40];
    int vgolove;
    int dgolove;
    int tochki;
    } otbori[500],tempotbor;
    I want to bring out 3 teams with the lowest points(tochki).
    What will happen? Thanks for the help.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You can sort them by points, then pick the lowest three. Actually, you don't need to sort, but that would probably be a simple way for now. Another simple way is to linear search three times, but it is not quite as simple as you need to avoid searching for what you already found.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2011
    Location
    Karnobat, Bulgaria
    Posts
    2
    Can you write the code because I am a beginner in C + + and do not understand much. Thanks.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yes, I can. However, if I do so before you have made your attempt, you will remain a beginner in C++ who does not understand much
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by ivanovbg View Post
    Can you write the code because I am a beginner in C + + and do not understand much. Thanks.
    Quote Originally Posted by laserlight View Post
    Yes, I can.
    Haha, we should add this as an example to the homework policy.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There is a sort function in the standard library. Take a look at it. If you don't understand it, that's fine. Just ask specific questions about what you don't understand and we'll help you create your own sorting code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed