frm Posted May 25, 2008 at 11:38 AM Report Share #187325 Posted May 25, 2008 at 11:38 AM Boas, tenho de fazer isto: Crie um programa que lance um processo filho onde: o processo filho gera um número aleatório de 0 a 9 e o processo pai vai tentar adivinhar esse número. As tentativas do pai são comunicadas ao filho por um pipe. O filho responde também por um pipe com -1, 1 ou 0 consoante a tentativa do pai esteja abaixo, acima ou tenha acertado no número. Uma vez acertado o número ambos os processos terminam. Agora as minhas duvidas. Como é que se utiliza o pipe? Como é que o filho responde por um pipe? Como meto o processo filho a gerar um numero aleatório? Link to comment Share on other sites More sharing options...
Rui Carlos Posted May 25, 2008 at 02:44 PM Report Share #187359 Posted May 25, 2008 at 02:44 PM Vê se isto ajuda: http://gsd.di.uminho.pt/members/jpo/2006-2007/pipes01_handout_2x4.pdf Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
Guest NoOne Posted June 12, 2008 at 10:48 AM Report Share #190845 Posted June 12, 2008 at 10:48 AM Para gerar número aleatorio: #include <time.h> #include <stdio.h> #include <stdlib.h> int main() { srand(time(NULL)); printf("%d", rand() % 9); return 0; } Link to comment Share on other sites More sharing options...
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