The program to be done;

Team Wins Losses Ties PF PA +/-
Blue 0 0 0 0 0 0
White 0 0 0 0 0 0
Red 0 0 0 0 0 0
Black 0 0 0 0 0 0
Green 0 0 0 0 0 0
Orange 0 0 0 0 0 0
Purple 0 0 0 0 0 0
Grey 0 0 0 0 0 0

Objective #1: user entered scores

  1. Your main program should ask the user to enter the score for two teams.

(a) The program should accept from the user the current team’s name, the opponent team’s name, and the final score for their game played. When submitting the score, the first number represents the score for the first team and the second number represents the score for the opponent’s team.
(b) Write a function that determines who won and who lost or if it was a tie. The function should then increase the number of points scored for (PF) and increase the number of points scored against (PA). Finally, the function should calculate the +/- (found by subtracting the number of PA from the number of PF). Have the function return all six variables in an array.

  1. In the main program, your program should continue to ask the user to enter the score of other match-ups and keep updating the table. Continue to add scores until the user enters done for the first team name (you may want to let the user know how to end the program). Display the final table of results with the top ranked team listed first, the second rank team listed second, etc. Top team should be the one with the most wins and then the most ties. If there is a tie, the team with the most points scored for (PF) ranks higher. If there is still a tie, the team with the least points scored against (PA) ranks higher. If there is still a tie, then the team name that comes first in alphabetical order ranks higher.
  2. If the user enters any other team name not in the table, ask the user to re-enter the name. If the user enters an invalid score (anything below zero or above 15), ask the user to re-enter the score.

Objective #2: scores from file

  1. Create an input test file that contains the score for different team match-ups. Ensure that every team has played all the other teams in the league (round-robin play). Your file should look like the following:

Ultimate Frisbee League Scores – Summer 2004
Blue,White,15,10
Red,Black,11,12
Green,Orange,14,14
.
.
.
Blue, Grey,9,15
(eof)

  1. Your program should read in this file, fill out the table of values and display the final results. Display the final table of results with the top ranked team listed first, the second rank team listed second, etc. Top team should be the one with the most wins and then the most ties. If there is a tie, the team with the most points scored for (PF) ranks higher. If there is still a tie, the team with the least points scored against (PA) ranks higher. If there is still a tie, then the team name that comes first in alphabetical order ranks higher.

Objective #3: playoff format

  1. For the first round of playoffs, have the 1st place team play the 8th place team (Game 1), the 2nd place team play the 7th place team (Game 2), the 3rd place team play the 6th place team (Game 3), and the 4th place team play the 5th place team (Game 4). Display the match-ups and allow the user to enter the scores for each match-up in order to determine the second round of playoffs.

  2. For the second round of playoffs, have the winner of Game 1 play the winner of Game 4 (Game 5) and the winner of Game 2 play the winner of Game 3 (Game 6) in the championship round. Also have the loser of Game 1 play the loser of Game 4 (Game 7) and the loser of Game 2 play the loser of Game 3 (Game 8) in the consolation round. Display the match-ups and allow the user to enter the scores for each match-up in order to determine the third and final round of playoffs.

  3. For the third round of playoffs, have the winner of Game 5 play the winner of Game 6 for the championship and the winner of Game 7 play the winner of Game 8 for the consolation championship. Display the match-ups and allow the user to enter the scores for each match-up. Display the name of the championship winner and the name of the consolation championship winner.

My scrambled and unfinished code;

#include <stdio.h>
#include <stdlib.h>
#define SIZE 15



int main()
{
int a[][6] =  {


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0},


{ 0, 0, 0, 0, 0, 0}


} ;
func5(a,8,6);
// show( a,8,6);
//displayMatrix(8,6,a);


printf("\n");


/*FILE *fp, *fp2;
char teamName, teamName2;
int i, score1[5], score2[5];
printf("Enter the name of the two teams playing against each other");
scanf("current teamname %s score %d", teamName, score1);
scanf("opposite teamname %s score %d", teamName2, score2);



fp=fopen("MyFile.bin","w");
fwrite(&teamName,sizeof(char),15,fp);
fwrite(&score1,sizeof(int), 5, fp);
fwrite(&teamName2,sizeof(char),15,fp);
fwrite(&score2,sizeof(int), 5, fp);


*/



system("PAUSE");
return 0;
}


void swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}


void bubbleSort(int *array, int end)
{
int i;
end=end-1;
do{
for(i=0;i<end;++i)


if(*(array+i)>*(array+i+1))
swap(array+i, array+i+1);
end--;


}while(end>0);


}


int binary(int x, int v[], int n)
{
int low=0, high=n-1, mid;


while(low<=high)


if(x>v[mid])
low=mid+1;
else if (x<v[mid])
high=mid-1;


else


return mid;



return -1; // no match found
}


void displayMatrix (int nRows, int nCols, int matrix[nRows][nCols])
{
int row, column;


for(row=0; row<nRows; ++row){
for(column=0; column<nCols; ++column)
printf("%6i", matrix[row][column]);


printf("\n");
}


}



show( int (*p )[6], int r, int c )


{


int i, j ;


for(i=0; i<r ;i++ )


{


for(j=0; j<c ;j++ )


printf ("%d",*(*(p + i)+j)) ;


}


}


int func5(short *mat[8])
{
short i, j, *index[8];
for (i = 0 ; i < 8 ; i++)
index = (short *)mat + 3*i;


printf("\tblue team\n \black team");


printf("\t      Wins Losses");


for(i = 0 ; i < 8 ; i++)
{
printf("\n");
for(j = 0 ; j < 6 ; j++)
{
printf("%8d", index[j]);
}
}
printf("\n");
return;
}

I strongly need guidance to get through this assignment. This assignment is a matter of life to me, so to speak.

Edited 3 Years Ago by happygeek: fixed formatting

Comments
Use code tags.

what is it you want to do?
what is it you have done?
what is it that's not going as planned?

Just showing a bunch of code and pasting your assignment, then expecting someone to do all the work for you isn't going to help you.

And if it's really a life and death situation maybe we'd be better off without you if you can't do the job seeing as you seem incapable of doing more than write a few utility functions (or more likely paste them from a tutorial).

This article has been dead for over six months. Start a new discussion instead.