LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2005, 04:16 AM   #1
ewt3y
Member
 
Registered: May 2005
Location: hanoi vietnam
Distribution: mandriva
Posts: 106

Rep: Reputation: 15
too much headache this function


Ladies and gentlemen, please meet my requirement to have a random array generator function: (no member in this array is equal)


int RanGen [20] ( int range ) {
int RNum, count = 0, count1, count2;

for (count1=0; count1 <20 ; ) {
RNum = random ( range );
RanGen [count++] = RNum;
for (count2=0;count2<count;count2++){
if (RNum==RanGen[count] {
count--;
}
}
}

}
 
Old 08-11-2005, 10:39 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
You really should review how to define a function.
Code:
int RanGen [20] ( int range )
That is not legal.
 
Old 08-11-2005, 12:10 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Along with other threads you've started, this just has to be homework... please do NOT ask homework questions here, it's for you to learn for yourself, not be given an answer cold.
 
Old 08-12-2005, 04:39 AM   #4
ewt3y
Member
 
Registered: May 2005
Location: hanoi vietnam
Distribution: mandriva
Posts: 106

Original Poster
Rep: Reputation: 15
My lud, after millenniums of being disdained by tc, I'm frustrating. So I need your objective view. Please keep me sweet.


Hitler's follower.
 
Old 08-12-2005, 05:12 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I beg your pardon??? you're either reading through a vietnamese translator, or you're just being odd... let's be a little more civilized please.
 
Old 08-13-2005, 06:08 AM   #6
ewt3y
Member
 
Registered: May 2005
Location: hanoi vietnam
Distribution: mandriva
Posts: 106

Original Poster
Rep: Reputation: 15
I got down on my knees !
Code:
int i [20], j, k, l;
RanIntArrayGen() {
	randomize();
	for( k=0; k<21;) {
		x:;
		j=random(21);
		for( l=0; l<k; l++) {
			if( i[l]==j)
				goto x;
		}
		i [k]=j;
		k++;
	}

}
 
Old 08-13-2005, 12:19 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
knees??? yeah just reposting exactly the same code doesn't change what appears to not only be homework, but not even a real question at any stage.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling another function from a function using GTK geminigal Programming 4 07-11-2005 03:15 PM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 01:44 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
Is the wait function is the same as the sleep function ? Linh Programming 3 04-28-2004 12:39 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration