Hey there! Sign in to join this conversationNew here? Join for free
x Turn on thread page Beta

C programming help - how to randomize a list? watch

Announcements
    • Thread Starter
    Offline

    4
    ReputationRep:
    I have a program that gets a list of 16 names for a tournament of 8 matches, but i was wondering how to randomize the list to get the 8 matches at random?

    this is my code so far: http://pastebin.com/mK21KQA4

    helppppp x) i've never done any programming before this module hahahaha
    Offline

    19
    ReputationRep:
    If you can upgrade yourself to C++, it appears there is a shuffle function for precisely this purpose!

    http://www.cplusplus.com/reference/algorithm/shuffle/

    Good luck!
    • Thread Starter
    Offline

    4
    ReputationRep:
    (Original post by ByEeek)
    If you can upgrade yourself to C++, it appears there is a shuffle function for precisely this purpose!

    http://www.cplusplus.com/reference/algorithm/shuffle/

    Good luck!
    i wish i could teacher wants it to be in c
    Offline

    19
    ReputationRep:
    Ah I see. Well in that case perhaps one should keep my cards a bit closer least you be accused of cheating. It is an interesting problem to solve. Using the rand() function will not work because the sequence returned is the same each time. A clue is to use time to provide a modicum of unpredictability. There are solutions online that are easy to find but where is the fun in that?

    Good luck!
    • PS Helper
    Offline

    2
    ReputationRep:
    PS Helper
    (Original post by infinitytheory)
    I have a program that gets a list of 16 names for a tournament of 8 matches, but i was wondering how to randomize the list to get the 8 matches at random?
    Try reading through this: https://en.wikipedia.org/wiki/Knuth_shuffle
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: November 4, 2015
Poll
Do you agree with the proposed ban on plastic straws and cotton buds?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.