# Thread: [Solution Needed] Structures questions

1. ## [Solution Needed] Structures questions

Create a structure of a university ACM ICPC team that contains 6 strings of maximum 50
characters (described in details below), number of problems solved (an integer),
and finally their penalty points (an integer).
Each of the 6 string represents one name. The first name is the team name, then the institution
name, then the coach name, and finally the last three names are the contestant names.
ACM International Collegiate Programming Contest - Wikipedia, the free encyclopedia

b. After the structure type is created, create three teams: t1, t2, t3, with the following data from a
recent mock / training contest:
Code:
t1 = {NUSSOC1, NUS, Steven, Victor, Adhiraj, Hung, 4, 448}
t2 = {NUSSOC2, NUS, Steven, Duc, Tien, Phong, 6, 716}
t3 = {NUSSOC3, NUS, Steven, Haocong, BiRan, Daniel, 5, 755}

c. Finally, use C code to do these operations:
1. Check which one between struct t1, t2, or t3 is rank 1 in this ‘mock contest’.
In ICPC, team is ranked based on number of problems solved.
The answer is unique in this instance.
2. Check which one between t1, t2, or t3 has team name equals to “NUSSOC1”,
then display the coach name of that team.
3. Suppose team t3 (NUSSOC3) solved another problem at minute 250, increased their number
of problems solved by 1 and penalty points by 250. Update t3 and print the updated number
of problems solved and the penalty points of t3.

There is 3 parts in this question.

Thank you very much =D

2. What part are you having problems with? Show your attempt, any errors you get, and specifically what you can or cannot figure out.

Quzah.

3. Originally Posted by quzah
What part are you having problems with? Show your attempt, any errors you get, and specifically what you can or cannot figure out.

Quzah.
Hi quzah thanks for the reply.
Here is what i did.. but when i compare the team name.. it doesnt work. and i dont know how to approach the 3rd portion

Code:
#include <stdio.h>
#include <string.h>

struct icpc{
char team[8];
char insitution[8];
char coach[8];
char c1[8];
char c2[8];
char c3[8];
int solved, penalty;
};

int main()
{
struct icpc t1 = {"NUSSOC1","NUS","Steven","Victor","Adhiraj","Hung", 4, 448}, t2 = {"NUSSOC2","NUS","Steven","Duc","Tien","Phong", 6, 716}, t3 = {"NUSSOC3","NUS","Steven","Haocong","BiRan","Daniel", 5, 755};

if(t1.solved>t2.solved && t1.solved>t3.solved)
printf("Team 1 is rank 1.\n");
if(t2.solved>t1.solved && t2.solved>t3.solved)
printf("Team 2 is rank 1.\n");
if(t3.solved>t1.solved && t3.solved>t2.solved)
printf("Team 3 is rank 1.\n");

if(t1.team == "NUSSOC1"){
printf("%s\n",t1.coach);
printf("12345\n");
}
if(t2.team == "NUSSOC1")
printf("%s\n",t2.coach);
if(t2.team == "NUSSOC1")
printf("%s\n",t3.coach);

}

4. (26): warning C4130: '==' : logical operation on address of string constant
(30): warning C4130: '==' : logical operation on address of string constant
(32): warning C4130: '==' : logical operation on address of string constant

Use strcmp to compare strings, not ==. Using == will compare a pointer to another pointer, which will never be true.