Jump to content

Chave totoloto


costricardo
 Share

Recommended Posts

Boas pessoal,

Queria fazer um programa que me deixa sse introduzir a chave de um totoloto, mas que nao me deixasse introduzir numeros ja repetidos nas anteriores posições de memória.

o meu código esta assim:

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

int main()
{
    int chave[6],i,j;

    for(i=0; i<6; i++) {
        for(j=i; j>0; j--) {
            do{
                printf("Num %d= ", i+1);
                scanf(" %d", &chave[i]);
            } while(chave[i] == chave [j]);
        }
    }

    printf(" %d", chave[i]);
    return 0;
}

I´m a Geek and you?www.tecnologias.in

Link to comment
Share on other sites

ja esta

int main()
{
    int chave[6],i,j;

    for(i=0; i<6; i++) {
        printf("Num %d = ", i+1);
        scanf(" %d", &chave[i]);

        for(j=0;j<i;j++) {
           if(chave[i]== chave[j]){
               printf("Num %d = ", i+1);
               scanf(" %d", &chave[i]);
               j=j-1;
           }
       }
    }

    printf(" %d", chave[i]);
    return 0;
}

I´m a Geek and you?www.tecnologias.in

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.