Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- int main()
- {
- int i, j, k, num[6], v[6], aux, ac = 0;
- //Números escolhidos:
- for(i=0;i<=5;i++)
- {
- printf("\nvalor %d: ", i+1);
- scanf("%d", &v[i]);
- if(v[i]>60 || v[i]<1)
- {
- printf("\nValor Invalido\n");
- i--;
- }
- }
- printf("\nNumeros Sorteados:\n");
- //Números sorteados aleatoriamente
- srand(time(0));
- for(j=0;j<=5;j++)
- {
- num[j]=1+rand()%10;
- for(k=0;k<j;k++)
- {
- if(num[k]==num[j])
- {
- num[j]=1+ rand()%10;
- k=0;
- }
- }
- printf("%d\t", num[j]);
- }
- //Teste
- for(i=0;i<=5;i++)
- for(j=0;j<=5;j++)
- if(v[i]==num[j])
- ac++;
- printf("Acertos: %d", ac);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement