Design a game in c, C/C++ Programming

Design a game in c:

const DODGERS = 0;

const GIANTS = 1;

 

void main(void)

{

   int scoreboard [2][9];    // An array two rows by nine columns

   int team, inning;

   int score, total;

 

   randomize();              // Initialize random number generator

 

   // Generate the scores

   for (team = DODGERS; team <= GIANTS; team++) {

      for (inning = 0; inning < 9; inning++) {

         score = random(3);

         if (score == 2)             // 1/3 chance to score at least a run

            score = random(3) + 1;   // 1 to 3 runs

         if (score == 3)

            score = random(7) + 1;   // Simulates chance of a big

                                     // inning of 1 to 7 runs

         scoreboard[team][inning] = score;

      }

   }

 

   // Print the scores

   cout << "\nInning\t1   2   3   4   5   6   7   8   9  Total\n";

   cout << "Dodgers\t";

   total = 0;

   for (inning = 0; inning <= 8; inning++) {

      score = scoreboard[DODGERS][inning];

      total += score;

      cout << score << "   ";

   }

   cout << total << "\n";

 

   cout << "Giants\t";

   total = 0;

   for (inning = 0; inning < 9; inning++) {

      score = scoreboard[GIANTS][inning];

      total += score;

      cout << score << "   ";

   }

   cout << total << "\n" ;

}

 

 

Posted Date: 10/18/2012 7:52:24 AM | Location : United States







Related Discussions:- Design a game in c, Assignment Help, Ask Question on Design a game in c, Get Answer, Expert's Help, Design a game in c Discussions

Write discussion on Design a game in c
Your posts are moderated
Related Questions
Problem: (a) Show the Java approach to event processing by explaining how event handling works in Java. Make use of a suitable example to support your answer. (b) Describe

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.     #include float start

Help for tomorrow...?

Write a C program to calculate the output Y for a given value of X for the following formula   Y=X 2 + 2X +3   #include stdio.h   void main()   {   char promt;   float y,x

Question: (a) Explain a linked list. (b) Describe the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

Simple program of c++: int main() {    int   bushels;    float dollars, rate;                 cout                 cin >> dollars;                 cout

A: No. (Excluding if you have an old compiler, you might have to force the new operator to throw an exception if it runs out of memory.) This turns out to be a real pain to alwa

Q: In p = new Fred(), does the Fred memory "leak" if  Fred constructor throws an exception? A: No.         If an exception take place during the Fred constructor of p = new F

Project Description: I want an app that the user can download it from the play store and use it as a keyboard for texts and writing. Just like the Samsung keyboard and the arabi