• 0
Sign in to follow this  
Thiago André Cardoso

Questão da OBI nível junior - respondida ALBUM DA COPA


Segue link com o caderno de perguntas: https://olimpiada.ic.unicamp.br/static/extras/obi2018/provas/ProvaOBI2018_f1pj.pdf

Segue resposta em C http://rextester.com/YVQ45070

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int N;
    int f_compradas;
    int repetidas = 0;
    int f_repetidas = 0;
    int f_n_repetidas = 0;
    int f_restantes = 0;
    printf("Qual o número máximo de figurinhas do album?\n");
    scanf("%i", &N);
    int M[N];
    printf("\nQuantidade de figuras compradas?\n");
    scanf("%i", &f_compradas);

    for (int i = 0; i < f_compradas; i++) {
        printf("\nDigite o numero da figura:");
        scanf("%i", &M[i]);
    printf("Saiu do laço\n");

    for (int i = 0; i < f_compradas - 1; i++) {
        for (int j = i + 1; j < f_compradas; j++) {
            if (M[ i ] == M[ j ]) {
                printf("Repetiu figura\n");
    f_n_repetidas = f_compradas - repetidas;
    f_restantes = N - f_n_repetidas;

    printf("\nQuantidade restante: %i\n", f_restantes);



Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this