URI / BEE CROWD 1131 - Grenais - Solution in C,C++,Python | URI - BEECROWD - BEE 1131 Solution in C,C++,Python

URI / BEE CROWD 1131 - Grenais - Solution in C,C++,Python | URI - BEECROWD - BEE 1131 Solution in C,C++,Python

                                                                                             beecrowd | 1131

Grenais

Adapted by Neilor Tonin, URI  Brazil

                                                                                             Timelimit: 1


URI / BEE CROWD 1131 - Grenais - Solution in C,C++,Python | URI - BEECROWD - BEE 1131 Solution in C,C++,Python:

The Federação Gaúcha de Futebol invited you to write a program to present a statistical result of several GRENAIS. Write a program that read the number of goals scored by Inter and the number of goals scored by Gremio in a GRENAL. Write the message "Novo grenal (1-sim 2-nao)" and request a response. If the answer is 1, two new numbers must be read (another input case) asking the number of goals scored by the teams in a new departure, otherwise the program must be finished, printing:

- How many GRENAIS were part of the statistics.
- The number of victories of Inter.
- The number of victories of Gremio.
- The number of Draws.
- A message indicating the team that won the largest number of GRENAIS (or the message: "Não houve vencedor" if both team won the same quantity of GRENAIS).

Input

The input contains two integer values​​, corresponding to the goals scored by both teams. Then there is an integer (1 or 2), corresponding to the repetition of the algorithm.

Output

After each reading of the goals it must be printed the message "Novo grenal (1-sim 2-nao)". When the program is finished, the program must print the statistics as the example below.

Input SampleOutput Sample

3 2
1
2 3
1
3 1
2

Novo grenal (1-sim 2-nao)
Novo grenal (1-sim 2-nao)
Novo grenal (1-sim 2-nao)
3 grenais
Inter:2
Gremio:1
Empates:0
Inter venceu mais

N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1131 Solution in C :   

  URI / BEECROWD Online Judge 1131 Solve  in C :                                          

#include <stdio.h>
int main()
{
    int a,b,c=0,d=0,e=0,f,g,h,i,j=0,k=0,l=0;
    while(1)
    {
        scanf ("%d%d", &a, &b);
        if(a>b) l++;
        if(a<b) k++;
        if(a==b) j++;
        c+=a;
        d+=b;
        e++;
        printf("Novo grenal (1-sim 2-nao)\n");
        scanf("%d",&f);
        if(f==1)
            continue;
        if(f==2)
            break;
    }
    printf("%d grenais\n",e);
    printf("Inter:%d\n",l);
    printf("Gremio:%d\n",k);
    printf("Empates:%d\n",j);
    if(l>k)
        printf("Inter venceu mais\n");
    if(l<k)
        printf("Gremio venceu mais\n");
    if(k==l)
        printf("Nao houve vencedor\n");
    return 0;
}

0 Response to URI / BEE CROWD 1131 - Grenais - Solution in C,C++,Python | URI - BEECROWD - BEE 1131 Solution in C,C++,Python

Post a Comment