Results 1 to 3 of 3
Hello , Iam begiener in linux programming with c , Ineed help for program that search for randum number in network(one server and aclients) using C language under linux.
thanks...
- 01-19-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 2
please help me for this program
Hello , Iam begiener in linux programming with c , Ineed help for program that search for randum number in network(one server and aclients) using C language under linux.
thanks
- 01-19-2008 #2
You're a beginner in C, right? I'm thinking, rather than one of us do your work for you, that if you start by trying to write the C program yourself and asking us, "Why won't this work?" or "I'm trying to write code that does xxx; will this chunk of code do the job?", then you will learn C much better.
While you're doing that, I'd like to raise a thought.
If you're going to search for a random number, how do you recognize that a number is random?
Is this number (sequence of digits) random?
78539
Or, is this number (sequence of digits) random?
If it's random, how do you know it is?Code:78539816339744830961566084581987572104929234984377 64552437361480769541015715522496570087063355292669 95537021628320576661773461152387645557931339852032 12027936257102567548463027638991115573723873259549 11072027439164833615321189120584466957913178004772 86412141730865087152613581662053348401815062285318 43114675165157889704372038023024070731352292884109 19731475900028326326372051166303460367379853779023 58264317591439897988273046529345483152948276279637 01861559499068739183797143818122280698454575298728 24584183406101641607715053487365988061842976755449 65235925692634804294073294188096168704616917351283 00014203178631589020694644283568944740229340929468 03671102253062383575366373963427626980699223147308 85504989028032255490216008604539953407443692827490 12967680283749999959324451248776493293320402407964 87561148638367270756606305770633361712588154827970 42752500784459688221646883302095355154294417286825 89956337260718886718278989071597058844689843798944 54644451330428067016532504819691527989773041050497
If it's not random, and I were to add a new digit by using the same rules by which these digits were generated, what would be the next digit?
The answer is: It's not random, and the next digit would be 3. What you're looking at is the first 1000 digits of pi/4.
So how will you know that what you're looking at is a random number?
(I owe this illustration to Douglas R. Hofstadter's highly overrated but nonetheless excellent book Goedel, Escher, Bach: an Eternal Golden Braid.)--
Bill
Old age and treachery will overcome youth and skill.
- 01-20-2008 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 2
Thanks for reply, I try for that program search for randum in one machine(computer),but I coud't make that one search for that number in network .and once that process find that number must make kill the other process, please try to help me again , I need that source code today .
this is aprogram that search for randum in one pc
#include <stdio.h>
#include <time.h>
int main ( )
{
/*meeee*/
struct timespec tim1,tim2;
/*end meeee*/
int r,j;long Bst,Fst, Totime,Total=0,i;float avg;
unsigned int seed=(unsigned)time(NULL);
srand(seed);
/*The rang*/
printf("Enter the range please: ");
scanf("%d",&r);
long random;
/*Generate random number*/
for (j=0; j<5; j++)
{
random = rand() % r;
printf("Random is %d:\n",random);
gettimeofday(&tim1,NULL);
printf("Time for begin search is %d \n",tim1.tv_nsec);
//Bst = tim1.tv_nsec;
i=0;
while(i !=random && i<=r)
{
i++;
}
if (i==random){
gettimeofday(&tim2,NULL);
printf("Time for Find Random is %d \n",tim2.tv_nsec);
//Fst = tim2.tv_nsec;
Totime=(int)difftime(tim2.tv_nsec,tim1.tv_nsec);
Total=Total+Totime;
printf("The TotalTime is %d \n",Total);
}
}//end for
avg = (float)Total/5;
printf("The Average Time is %f\n",avg);
return 0;
}
thanks


Reply With Quote
