Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Formatting with a 1st discarded rand loop

scuba22scuba22 Member Posts: 61

Hi all,
i have a question regarding my formatting.
i am looping an outside loop of Number of games for an output of 5 Games played.
The Game results are generated by rand, and [code]srand(unsigned)time(0)) [/code]for the seed. To avoid generating my first Game without a time change I am using an
incrementer at the end of the 5 game set and beginning my sets with
[code]if (i!=0)[/code]
what is happening is my prgram discards the first run and begins on the second when the time has changed, which i am told is desireable.
My problem is because of the first empty loop the space betweem my Header "Game 1" and the randomly generated scores is one line greater than every other game. giving me an out put like this:

Game # 1
// I don't want this space
5 12 4 8 1 10 12 10 1 2
7 12 2 10 10 6 12 8 6 5
4 8 11
First 11 was on roll 23



Game # 2
4 1 3 8 6 1 2 1 12 9
5 6 6 3 5 2 1 8 4 6
2 6 1 3 5 12 12 9 2 12
6 10 12 4 4 10 8 12 8 4
12 6 1 12 1 11
First 11 was on roll 46

anyone know how I can avoid the endlines when doing my first discarded loop?
thanks
Michele /scuba22

Comments

  • brycebryce Member Posts: 25
    Can you show me a little more code?
    I would like to see if you are using
    srand() and rand().

    I need to see the seed, and that is not
    a pick up line :-)

    I have a mid term in logic this Tuesday
    along with a brute force C assignment
    due Monday night.

    If you show me a little more I may respond
    with the desired format tonight if you did
    not already get an answer.

    I apologize I did not read this post or the
    other before sending you the 2'nd message.

    Bryce

    :
    : Hi all,
    : i have a question regarding my formatting.
    : i am looping an outside loop of Number of games for an output of 5 Games played.
    : The Game results are generated by rand, and [code]srand(unsigned)time(0)) [/code]for the seed. To avoid generating my first Game without a time change I am using an
    : incrementer at the end of the 5 game set and beginning my sets with
    : [code]if (i!=0)[/code]
    : what is happening is my prgram discards the first run and begins on the second when the time has changed, which i am told is desireable.
    : My problem is because of the first empty loop the space betweem my Header "Game 1" and the randomly generated scores is one line greater than every other game. giving me an out put like this:
    :
    : Game # 1
    : // I don't want this space
    : 5 12 4 8 1 10 12 10 1 2
    : 7 12 2 10 10 6 12 8 6 5
    : 4 8 11
    : First 11 was on roll 23
    :
    :
    :
    : Game # 2
    : 4 1 3 8 6 1 2 1 12 9
    : 5 6 6 3 5 2 1 8 4 6
    : 2 6 1 3 5 12 12 9 2 12
    : 6 10 12 4 4 10 8 12 8 4
    : 12 6 1 12 1 11
    : First 11 was on roll 46
    :
    : anyone know how I can avoid the endlines when doing my first discarded loop?
    : thanks
    : Michele /scuba22
    :

  • Andre YoungAndre Young USAMember Posts: 0

    _____ | http://forcoder.org | free ebooks and video tutorials about [ Visual Basic .NET Python Perl Assembly Ruby Objective-C R Go Delphi C++ C# MATLAB PHP Scratch Java C Visual Basic JavaScript Swift PL/SQL Ada Alice VBScript Clojure F# Prolog FoxPro Dart Hack ABAP Crystal Scala Julia Rust Awk D SAS Logo Fortran COBOL LabVIEW Scheme Lisp Bash Erlang Lua ML Apex Kotlin Transact-SQL ] _____

Sign In or Register to comment.