Question

WRITE A CODE USING C PROGRAMMING LANGUAGE: PSUT planning to organize a Football champion by eight...

WRITE A CODE USING C PROGRAMMING LANGUAGE:

PSUT planning to organize a Football champion by eight teams where the first round has two groups and then the best two of then continue to the next round until we achieve the champion. A) The each round you will create a 2D array and you will use Random algorithm to determine the winner (the function still running until finding the best two teams) 0 lost 1 Drawn 2 win B) Then you will create a 1D to calculate the points C) Then you will create a 2D for the second round and the loser will not be continued D) Your program will determine the 1st,2nd,3rd,4th by using the sort algorithm (Bubble sort) by using the function E) Use function to determine the best team and worst one, according to the result of the matches' team played.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the solution to your question. I tried my best to solve your doubt, however, if you find it is not as good as expected by you. Please do write your further doubts regarding this question in the comment section, I will try to resolve your doubts regarding the submitted solution as soon as possible.
If you think, the solution provided by me is helpful to you please do an upvote.

1. 2. #include <stdio.h> #include <stdlib.h> #include<time.h> langu creat visibil 3. 4. 5. Yo pa void bubbleSort(int points[]

#include <stdio.h>

#include <stdlib.h>

#include<time.h>


void bubbleSort(int points[],char team[], int n)

{

int i, j;

for (i = 0; i < n-1; i++)

{

for (j = 0; j < n-i-1; j++)

{

if (points[j] < points[j+1])

{

int pt=points[j];

char tm=team[j];

points[j]=points[j+1];

team[j]=team[j+1];

points[j+1]=pt;

team[j+1]=tm;

}

}

}

}



void play_game(void)

{

int winp[4];

char wint[4];

char team1[4]={'A','B','C','D'};

char team2[4]={'E','F','G','H'};

int round=0;

srand(time(0));

int ar[4-round][4-round];

for(int i=0;i<4-round;i+=1)

{

for(int j=0;j<4-round;j+=1)

{

ar[i][j]=rand()%3;

}

}

printf("\n\tRound %d\n\n\t ",round+1);

for(int i=0;i<4-round;i+=1)

{

printf("%c\t",team1[i]);

}

for(int i=0;i<4-round;i+=1)

{

printf("\n%c",team2[i]);

for(int j=0;j<4-round;j+=1)

{

printf("\t%d",ar[i][j]);

}

}

printf("\n");

int points1[4-round];

int points2[4-round];

// deciding points....

// assuming if row value is 1, then coressponding team wins

// assuming if column value is 2, then coressponding team wins

for(int i=0;i<4-round;i+=1)

{

points1[i]=0;

points2[i]=0;

for(int j=0;j<4-round;j+=1)

{

if(ar[i][j]==1)

points2[i]+=1;

if(ar[j][i]==2)

points1[i]+=1;

}

}

printf("\nPoints for group 1:\t");

for(int i=0;i<4-round;i+=1)

{

printf("%d\t",points1[i]);

}

printf("\nPoints for group 2:\t");

for(int i=0;i<4-round;i+=1)

{

printf("%d\t",points2[i]);

}

printf("\n");

bubbleSort(points1,team1, 4-round);

bubbleSort(points2,team2, 4-round);

printf("\nLoosing teams of group 1\t %c, %c\n",team1[4-round-2],team1[4-round-1]);

//points1[4-round-2]=-1;

//points1[4-round-1]=-1;

printf("Loosing teams of group 2\t %c, %c\n",team2[4-round-2],team2[4-round-1]);

//points2[4-round-2]=-1;

//points2[4-round-1]=-1;



// round 2

round=2;

srand(time(0));

int ar1[4-round][4-round];

for(int i=0;i<4-round;i+=1)

{

for(int j=0;j<4-round;j+=1)

{

ar1[i][j]=rand()%3;

}

}

printf("\n\tRound %d\n\n\t ",round);

for(int i=0;i<4-round;i+=1)

{

printf("%c\t",team1[i]);

}

for(int i=0;i<4-round;i+=1)

{

printf("\n%c",team2[i]);

for(int j=0;j<4-round;j+=1)

{

printf("\t%d",ar[i][j]);

}

}

printf("\n");

// deciding points....

// assuming if row value is 1, then coressponding team wins

// assuming if column value is 2, then coressponding team wins

for(int i=0;i<4-round;i+=1)

{

points1[i]=0;

points2[i]=0;

for(int j=0;j<4-round;j+=1)

{

if(ar1[i][j]==1)

points2[i]+=1;

if(ar1[j][i]==2)

points1[i]+=1;

}

}

printf("\nPoints for group 1:\t");

for(int i=0;i<4-round;i+=1)

{

printf("%d\t",points1[i]);

}

printf("\nPoints for group 2:\t");

for(int i=0;i<4-round;i+=1)

{

printf("%d\t",points2[i]);

}

printf("\n");

int npoints[4];

char nteams[4];

npoints[0]=points1[0];

nteams[0]=team1[0];

npoints[1]=points1[1];

nteams[1]=team1[1];

npoints[2]=points2[0];

nteams[2]=team2[0];

npoints[3]=points2[1];

nteams[3]=team2[1];

bubbleSort(npoints, nteams, 4);

wint[3]=nteams[3];

printf("\n%c Loose",wint[3]);


// round 3

round=3;

srand(time(0));

int ar2[3][3];

for(int i=0;i<3;i+=1)

{

ar2[i][i]=0;

for(int j=0;j<i;j+=1)

{

if(rand()%3==2)

{

ar2[i][j]=2;

ar2[j][i]=1;

}

else

{

ar2[i][j]=1;

ar2[j][i]=2;

}

}

}

printf("\n\tRound %d\n\n\t ",round);

for(int i=0;i<3;i+=1)

{

printf("%c\t",nteams[i]);

}

for(int i=0;i<3;i+=1)

{

printf("\n%c",nteams[i]);

for(int j=0;j<3;j+=1)

{

printf("\t%d",ar2[i][j]);

}

}

printf("\n");

// deciding points....

// assuming if row value is 1, then coressponding team wins

for(int i=0;i<3;i+=1)

{

npoints[i]=0;

for(int j=0;j<3;j+=1)

{

if(ar2[i][j]==1)

npoints[i]+=1;

}

}

printf("\nPoints for group :\n%c\t%c\t%c\n",nteams[0],nteams[1],nteams[2]);

for(int i=0;i<3;i+=1)

{

printf("%d\t",npoints[i]);

}

printf("\n");


bubbleSort(npoints, nteams, 3);

wint[2]=nteams[2];

printf("\n%c Loose",wint[2]);


// round 4

round=4;

srand(time(0));

int ar3[2][2];

for(int i=0;i<2;i+=1)

{

ar3[i][i]=0;

for(int j=0;j<i;j+=1)

{

if(rand()%3==2)

{

ar3[i][j]=2;

ar3[j][i]=1;

}

else

{

ar3[i][j]=1;

ar3[j][i]=2;

}

}

}

printf("\n\tRound %d\n\n\t ",round);

for(int i=0;i<2;i+=1)

{

printf("%c\t",nteams[i]);

}

for(int i=0;i<2;i+=1)

{

printf("\n%c",nteams[i]);

for(int j=0;j<2;j+=1)

{

printf("\t%d",ar3[i][j]);

}

}

printf("\n");

// deciding points....

// assuming if row value is 1, then coressponding team wins

for(int i=0;i<2;i+=1)

{

npoints[i]=0;

for(int j=0;j<2;j+=1)

{

if(ar3[i][j]==1)

npoints[i]+=1;

}

}

printf("\nPoints for group :\n%c\t%c\n",nteams[0],nteams[1]);

for(int i=0;i<2;i+=1)

{

printf("%d\t",npoints[i]);

}

printf("\n");


bubbleSort(npoints, nteams, 2);

wint[1]=nteams[1];

printf("\n%c Loose",wint[1]);


wint[0]=nteams[0];

printf("\n\tResults\n");

printf("\n1st is %c\n",wint[0]);

printf("\n2nd is %c\n",wint[1]);

printf("\n3rd is %c\n",wint[2]);

printf("\n4th is %c\n",wint[3]);





}

int main(void)

{

play_game();

return 0;

}

" Your question is a little bit confusing because you are providing only the task, there is no screenshot mentioning how to output. I request you, next time when you ask a question, please provide an input-output test case. "

Add a comment
Know the answer?
Add Answer to:
WRITE A CODE USING C PROGRAMMING LANGUAGE: PSUT planning to organize a Football champion by eight...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please need help, programming in C - Part A You will need to create a struct...

    Please need help, programming in C - Part A You will need to create a struct called Team that contains a string buffer for the team name. After you've defined 8 teams, you will place pointers to all 8 into an array called leaguel], defined the following way: Team leaguel8]. This must be an aray of pointers to teams, not an array of Teams Write a function called game) that takes pointers to two teams, then randomly and numerically determines...

  • You have to use Binary Tree ADT. Problem Use Java as Programming Language Define an ESports...

    You have to use Binary Tree ADT. Problem Use Java as Programming Language Define an ESports World Cup class that implements the E-Games World Cup using a Binary Tree ADT. The external nodes of the tree correspond to each competing player. The internal nodes correspond to games played at different rounds of the cup (i.e. root of the tree is the final game, its children are the semifinals, etc.). Two players compete against each other and the winner goes to...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • Create a complete pseudo-code program in C++ to do the following using the PseudoCode language developed...

    Create a complete pseudo-code program in C++ to do the following using the PseudoCode language developed in class using Absolute Addressing. There is 1 deliverable: 1. You should include the input cards shown below as a test. THE PROGRAM: First you will read in a value N which holds the number of values to be read in. (so if N is 20 then there will be 20 more cards to read in.) Read in N values into an array. Bubble-Sort...

  • ***PLEASE USE C++ LANGUAGE*** Binary Search of Strings 1. Write a version of the selection sort...

    ***PLEASE USE C++ LANGUAGE*** Binary Search of Strings 1. Write a version of the selection sort algorithm presented in the unit, which is used to search a list of strings. 2. Write a version of the binary search algorithm presented in the unit, which is used to search a list of strings. (Use the selection sort that you designed above to sort the list of strings.) 3. Create a test program that primes the list with a set of strings,...

  • MATLAB code help!!! Function Name: sportsStats Inputs: 1. (double) An Nx5 array representing the stats of different foo...

    MATLAB code help!!! Function Name: sportsStats Inputs: 1. (double) An Nx5 array representing the stats of different football teams 2. (double) The cutoff for total penalties Outputs: 1. (double) An Mx5 array representing the updated stats Background: You just finished watching the Patriots defeat the Rams in Super Bowl LIII, and you just can't wait for the next season to start. However, instead of waiting around for the next football season, you decide to take matters into your own hands...

  • C programming language Purpose The purpose of this assignment is to help you to practice working...

    C programming language Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms Learning Outcomes ● Develop skills with multidimensional arrays ● Learn how to traverse multidimensional arrays ● Passing arrays to functions ● Develop algorithm design skills (e.g. recursion) Problem Overview Problem Overview Tic-Tac-Toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the...

  • C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position p...

    C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position played, and at least 3 stats. Positions are small forward, power forward, center, shooting guard and point guard. 1. A.) Design a class with member variables and appropriate member functions Data should be stored in a read/write file consisting of team member’s names, jersey number, position played, and...

  • all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function,...

    all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function, no main is needed) that takes in a number and determines if it is evenly divisible by 5 (le, returns true or false). (15 points) Answer is in: Pseudocode CHO Java0 C+0 Page 17 Question 3) 2D Arrays The IRS has contracted you to process a 10x10 array of floating point numbers called Taxes and sum up all negative numbers in the array so...

  • Write an object-oriented C++ program (i.e. a class and a main function to use it), using...

    Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT