Please need help, programming in C
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
struct Team {
char name[100];
};
struct Team * game(struct Team *team1,struct Team *team2)
{
srand(time(0));//vary the seed of the psuedo number every
time
int scoreteam1 = rand();
int scoreteam2= rand();
struct Team *winner;
printf("\nTeams\tScore\n");
printf("%s\t%d\n",team1->name,scoreteam1);
printf("%s\t%d\n",team2->name,scoreteam2);
printf("\nWinner\tScore\n");
if(scoreteam1>scoreteam2)
{
printf("%s\t%d\n",team1->name,scoreteam1);
winner = team1;
}
else
{
printf("%s\t%d\n",team2->name,scoreteam2);
winner = team2;
}
return winner;
}
struct Team * tournament(struct Team *league[])
{
struct Team *round1Winner[4];
struct Team *round2Winner[2];
int i = 0, index=0;
printf("\n Round 1\n");
for(i=0;i<8;i+=2)
{
round1Winner[index]=game(league[i],league[i+1]);
index++;
}
printf("\nRound 1 Winners\n");
for(i=0;i<index;i++)
printf("%s\t",round1Winner[i]->name);
printf("\n Round 2\n");
index=0;
for(i=0;i<4;i+=2)
{
round2Winner[index]=game(round1Winner[i],round1Winner[i+1]);
index++;
}
printf("\nRound 2 Winners\n");
printf("%s\t%s",round2Winner[0]->name,round2Winner[1]->name);
printf("\nRound 3 Winners\n");
return game(round2Winner[0],round2Winner[1]);
}
int main()
{
struct Team *league[8];
int i=0;
for(i=0;i<8;i++)
{
league[i] = (struct Team *) malloc(sizeof(struct Team));
printf("Enter the team name\n");
scanf("%s",league[i]->name);
}
printf("Winner is :- %s",tournament(league)->name);
return 0;
}
Please need help, programming in C - Part A You will need to create a struct...
Using C Please comment Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing left, right, and parent pointers, in addition to holding an Data struct value Tree struct containing a pointer to the root of the tree A function declaration for a function that allocates a tree, and initializes the root to NULL o o o A...
C programming The program will require the following structure: struct _data { char *name; long number; }; The program will require command line arguments: int main(int argv, char **argc) { Where argv is the number of arguments and argc is an array holding the arguments (each is a string). Your program must catch any case where no command line arguement was provided and print a warning message (see below). You MUST include/use the following functions, defined as follows: int SCAN(FILE...
C++ Project - Create a memory game in c++ using structs and pointers. For this exercise, you will create a simple version of the Memory Game. You will again be working with multiple functions and arrays. You will be using pointers for your arrays and you must use a struct to store the move and pass it to functions as needed. Program Design You may want to create two different 4x4 arrays. One to store the symbols the player is...
In this exercise, you will make a struct that contains x and y coordinates: struct point {int x; int y;}; The object of this exercise is to make a singly linked list of these point structures. Add one more member called "next" to your point struct. It is a pointer to the next member of the linked list. The next member of the last point struct should point to NULL, which indicates the end of the list. Your program will...
Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
C programming. 1.Create a program that does the following - Creates three pointers, a character pointer professor, and two integer pointers student_ids, grades - Using dynamic memory, use calloc to allocate 256 characters for the professor pointer - Prompts the professor for their name, and the number of students to mark. - Stores the professor’s name using the professor pointer and in an integer the number of students to mark. - Using dynamic memory, use malloc to allocate memory for...
17.True or False: Algorithms should be specified in pseudocode before they are implemented in C. 18. True or False: In C, false is defined as any result that is zero. 19. True or False: An advantage to defining functions in C is that they may be reused in other projects. 20. True or False: Suppose a function main calls a function f. As a parameter to f, main passes a pointer p to a struct. Further suppose that f's body modifies p by...
Hey everyone, I need help making a function with this directions with C++ Language. Can you guys use code like printf and fscanf without iostream or fstream because i havent study that yet. Thanks. Directions: Write a function declaration and definition for the char* function allocCat. This function should take in as a parameter a const Words pointer (Words is a defined struct) The function should allocate exactly enough memory for the concatenation of all of the strings in the...
please answer the second part first part answered. the answer to the first part is at the bottom bring the rest of the place HAVE TO BE SOLVED WİTH C PROGRAMMİNG A programming task is given in below (i.e., you are supposed to write a single program involving all 5 tasks in below). You should write a C program and upload your c/cpp file . Students are allowed to use MAK104E course (powerpoint) slights. 1) Three geometric entities (a circle,...
This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...