Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. typedef struct teams{
  2. int victories, defeats, draws, goals_made, goals_suffered, games, points;
  3. char name[30];
  4. }TEAMS;
  5.  
  6.  
  7. int ret, ret2, cont, cont2;
  8. char caractere, caractere2;
  9. char line[30], line2[30];
  10. int i, j, k, l = 0, h = 0, n, t = 0, x = 30; //t = number of teams n = number of championships
  11. char championship[100];
  12. unsigned int g; //g = number of games already played in the championship
  13. char useless;
  14. int value1, value2;
  15.  
  16. TEAMS zoera[30];
  17.  
  18. scanf("%d", &n);
  19. fflush(stdin);
  20.  
  21. for(i = 0; i < n; i++){
  22. scanf("%[^n]", championship);
  23. scanf("%d", &t);
  24. for(j = 0; j < t; j++){
  25. scanf("%s", zoera[j].nome);
  26. }
  27.  
  28. scanf("%u", &g);
  29. for(k = 0; k < g; k++){
  30. //scanf("%s", azedo2[k]);
  31. do{
  32. caractere = getchar();
  33. line[l] = caractere;
  34. l++;
  35. }while(caractere != '#');
  36. for(cont = 0; cont < t; cont++){
  37. ret = strcmp(line, zoera[cont].nome);
  38. if(ret == 0){
  39. scanf("%c", &useless);
  40. scanf("%d", &value1);
  41. scanf("%c", &useless);
  42. scanf("%d", &value2);
  43. do{
  44. caractere2 = getchar();
  45. line2[h] = caractere2;
  46. h++;
  47. }while(caractere2 != 'n');
  48. for(cont2 = 0; cont2 < t; cont2++){
  49. ret2 = strcmp(line2, zoera[cont2].nome);
  50. if(ret2 == 0){
  51. zoera[cont].jogos += 1;
  52. zoera[cont2].jogos += 1;
  53. zoera[cont].gols_feitos += value1;
  54. zoera[cont2].gols_feitos += value2;
  55. zoera[cont].gols_sofridos += value2;
  56. zoera[cont2].gols_sofridos += value1;
  57. if(value1 > value2){
  58. zoera[cont].pontos += 3;
  59. zoera[cont].vitorias += 1;
  60. zoera[cont2].derrotas += 1;
  61. }
  62. if(value1 == value2){
  63. zoera[cont].pontos += 1;
  64. zoera[cont2].pontos += 1;
  65. zoera[cont].empates += 1;
  66. zoera[cont2].empates += 1;
  67. }
  68. else{
  69. zoera[cont2].pontos += 3;
  70. zoera[cont2].vitorias += 1;
  71. zoera[cont].derrotas += 1;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement