Gurzi Posted January 4, 2006 at 10:03 PM Report #10783 Posted January 4, 2006 at 10:03 PM #include <stdio.h> #include <stdlib.h> #include <time.h> int numeros[49]; int numero_gerado[4]; void inic(int nu[49],int gerador[4]) { int i,j; for(i=1;i<=50;i++) nu[i-1] = i; for(j=1;j<=5;j++) gerador[j] = j; } void mostra() { int i; for (i=0;i<=50;i++) { if (!(i%7)) putchar('n'); printf("%d ", i); } } void aleatorio(int s[4]) { int j; for (j=1;j<=5;j++) { time(numero_gerado[j]); srand((unsigned int)numero_gerado[j]); } } main() { int i,j; inic(numeros,numero_gerado); printf("Benvindo ao Jogo de Apostas do EuroEcol\n\n"); mostra(); getchar(); aleatorio(numero_gerado); srand((unsigned int)aleatorio); for (i=1;i<=50;i++) for (j=1;j<=5;j++) { if(numeros[i]== numero_gerado[4]) printf("XX"); else printf("%d",numeros[i]); } system("PAUSE"); } 33 d:\docume~1\tiagop~1\osmeus~1\exerci~1\testes.cpp passing `long int' to argument 1 of `inic(long int *, long int *)' lacks a cast estou aqui um pouco aterefado 😛
Bruno Posted January 4, 2006 at 10:07 PM Report #10787 Posted January 4, 2006 at 10:07 PM Exceptuando na função aleatorio e na main falta-te sempre um } a fechar as funções! 😛 EDIT: Falta-te tb em "printf("%d ", i)" e em "time(numero_gerado[ i ])" os ";" no fim! No aleatório falta-te declarar o i... etc 😄
Gurzi Posted January 4, 2006 at 10:09 PM Author Report #10788 Posted January 4, 2006 at 10:09 PM sim porque eu depois comecei a fazer umas modifcaçoes e este era o source inicial entao como o outro n deu pus aki este e eskecime de as fechar.. mas akele erro dá sempre
Bruno Posted January 4, 2006 at 10:10 PM Report #10789 Posted January 4, 2006 at 10:10 PM Eu editei o meu 1º e n sei se chegaste a ver o q escrevi depois! Repara esses erros e coloca aí o codigo depois se ainda der problema!
Bruno Posted January 4, 2006 at 10:13 PM Report #10791 Posted January 4, 2006 at 10:13 PM Outro erro teu nessa mm função é que declaras o i=0 e que ele vai até 50 (i<=50)... ora o vector "nu[ 49]" não tem esse numero de casas! Qd declares algo como abc[1] ele aloca espaço na memora para 2 casas... que são a abc[0] e a abc[1]! 😛
Gurzi Posted January 4, 2006 at 10:30 PM Author Report #10795 Posted January 4, 2006 at 10:30 PM sim boa tem que ser de 1 a 50 enganeime 😛
Bruno Posted January 4, 2006 at 10:33 PM Report #10799 Posted January 4, 2006 at 10:33 PM Nepes... tem de ser de 0 a 49 😛
Gurzi Posted January 4, 2006 at 10:41 PM Author Report #10802 Posted January 4, 2006 at 10:41 PM não, pode ser de 1 a 50 (sao 50 algarismos) visto que a var variavel[49] é igual a 50 algorismos, visto que o indice começa em 0. logo 49 +1 = 50 😄 a cena do lack a cast é que me está a partir a cabeça
Bruno Posted January 4, 2006 at 10:54 PM Report #10805 Posted January 4, 2006 at 10:54 PM Ok eu tinha dito mal mas tu tb estás a dizer... qd fazes var[49] declaras realmente 50 casas... mas essas casas são do 0 ao 49... o 50 já n existe! 😄
Gurzi Posted January 4, 2006 at 10:57 PM Author Report #10806 Posted January 4, 2006 at 10:57 PM sim mas aquilo é um for para atribuir de 1 a 50 o valor á var que é var[49] só que o 1 vai ser atribuido ao var[0] por isso no fim vai ser igual
Bruno Posted January 4, 2006 at 11:01 PM Report #10808 Posted January 4, 2006 at 11:01 PM Ok, portanto n poderás fazer isto, certo? for(i=1;i<=50;i++) nu[i ] = i;
Gurzi Posted January 4, 2006 at 11:03 PM Author Report #10809 Posted January 4, 2006 at 11:03 PM pois 😄 mas posso nu[i-1] = i 😄
Gurzi Posted January 4, 2006 at 11:04 PM Author Report #10811 Posted January 4, 2006 at 11:04 PM e acena do erro ja descobriste?
Bruno Posted January 4, 2006 at 11:06 PM Report #10812 Posted January 4, 2006 at 11:06 PM pois 😄 mas posso nu[i-1] = i 😄 Nem mais! 😄 e acena do erro ja descobriste? Já te pedi para actualizares o codigo todo :$ Eu sou mto de descubrir a testar e aquilo assim dá-me 10 erros! 😄
Gurzi Posted January 4, 2006 at 11:08 PM Author Report #10813 Posted January 4, 2006 at 11:08 PM a mim só me dá 1 erro no dev c++
Bruno Posted January 4, 2006 at 11:15 PM Report #10815 Posted January 4, 2006 at 11:15 PM A mim na função aleatorio dá este: 32 C:\Documents and Settings\Bruno\Desktop\Untitled1.cpp invalid conversion from `int*' to `time_t*' Do q percebi do teu codigo acho que tens outro erro: for (j=1;j<=5;j++) time(numero_gerado[j]); srand((unsigned int)numero_gerado[j]); Se queres q o time e o srand estejam ambos no ciclo for precisas de fazer um bloco 😄
Gurzi Posted January 4, 2006 at 11:20 PM Author Report #10816 Posted January 4, 2006 at 11:20 PM ok isso ja foi corrigido , é exactamente esse o erro que me dá :\
Bruno Posted January 4, 2006 at 11:28 PM Report #10818 Posted January 4, 2006 at 11:28 PM O time recebe um endereço de uma variavel do tipo time_t... exemplo: time_t t1; time(&t1); 😄 Ja agora dá uma olhadela pelas guardas dos outros ciclos for que tens no teu codigo porque têm erros como aqueles que já falamos! 😄 Declaration: time_t time(time_t *timer); Calculates the current calender time and encodes it into time_t format. The time_t value is returned. If timer is not a null pointer, then the value is also stored into the object it points to. If the time is unavailable, then -1 is returned. (fonte)
theproject Posted January 5, 2006 at 01:25 AM Report #10827 Posted January 5, 2006 at 01:25 AM nao sei ondek o compilador vai buskar a definicao de long int* na funcao inic, de kk maneira, experimenta mudares o cabecalho da funcao, em vez de void inic(int nu[49],int gerador[4]){ ... } para void inic(int* nu, int* gerador) hasta
Gurzi Posted January 5, 2006 at 07:06 AM Author Report #10832 Posted January 5, 2006 at 07:06 AM bruno n percebi como aquilo funciona :\
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now