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
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
01-22-2008, 03:37 PM
#1
Member
Registered: Apr 2007
Location: SC
Distribution: Kubuntu 20.04 LTS
Posts: 378
Rep:
package java program into .jar file
hi,
i have written a simple horse race game for my friends and now want to distribute it to some other people. How do i package my program into a .jar file? Do i need to include all the files i imported like java.io.*?
Here is the code
Code:
import java.io.*;
import java.util.*;
public class Horserace10
{
static Random gen = new Random();
public static void fx1()
{
int horse[] = new int[10];
int x, y, rand, a, p, d, z;
String n, pt, h;
Scanner p1, p2, p1h, p1b, p2h, p2b, hold;
horse[0] = 0;
horse[1] = 0;
horse[2] = 0;
horse[3] = 0;
horse[4] = 0;
horse[5] = 0;
horse[6] = 0;
horse[7] = 0;
horse[8] = 0;
horse[9] = 0;
rand = gen.nextInt(300);
System.out.print("Welcome to the Horse Race Game!" + "\n\n");
System.out.print("Enter Player 1's name" + "\n\n");
p1 = new Scanner(System.in);
n = p1.nextLine();
System.out.print("\n\nEnter Player 2's name" + "\n\n");
p2 = new Scanner(System.in);
pt = p2.nextLine();
System.out.print("\nEnter the horse number " + n + " wants to bet on" + " (1 - 10)" + "\n\n#");
p1h = new Scanner(System.in);
x = p1h.nextInt();
System.out.print("\nEnter how much money " + n + " wants to bet on Horse #" + x + "\n\n$");
p1b = new Scanner(System.in);
y = p1b.nextInt();
System.out.print("\nEnter the horse number " + pt + " wants to bet on\n\n#");
p2h = new Scanner(System.in);
p = p2h.nextInt();
System.out.print("\nEnter how much money " + pt + " wants to bet on Horse #" + p + " \n\n$");
p2b = new Scanner(System.in);
d = p2b.nextInt();
System.out.print("\nThe race has started!!, Press enter to continue the race");
a = rand + y + d;
z = rand + d + y;
do
{
System.out.print("\n");
for (int track = 0; track < 10; track++)
{
System.out.print("\n\n|");
for (int i = 0; i < 75; i++)
{
if (i != horse[track])
{
System.out.print("-");
}
else
{
System.out.print(track + 1);
}
}
System.out.print("|");
}
hold = new Scanner(System.in);
h = hold.nextLine();
horse[0] += gen.nextInt(3) + 1;
horse[1] += gen.nextInt(3) + 1;
horse[2] += gen.nextInt(3) + 1;
horse[3] += gen.nextInt(3) + 1;
horse[4] += gen.nextInt(3) + 1;
horse[5] += gen.nextInt(3) + 1;
horse[6] += gen.nextInt(3) + 1;
horse[7] += gen.nextInt(3) + 1;
horse[8] += gen.nextInt(3) + 1;
horse[9] += gen.nextInt(3) + 1;
}
while (horse[0] <= 75 && horse[1] <= 75 && horse[2] <= 75 && horse[3] <= 75 && horse[4] <= 75 && horse[5] <= 75 && horse[6] <= 75 && horse[7] <= 75 && horse[8] <= 75 && horse[9] <= 75);
if (horse[0] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 won the race!!");
}
if (horse[1] > 75 && horse[0] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 won the race!!");
}
if (horse[2] > 75 && horse[1] < 75 && horse[0] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 won the race!!");
}
if (horse[3] > 75 && horse[1] < 75 && horse[2] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 won the race!!");
}
if (horse[4] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 won the race!!");
}
if (horse[5] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 won the race!!");
}
if (horse[6] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 7 won the race!!");
}
if (horse[7] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 8 won the race!!");
}
if (horse[8] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 9 won the race!!");
}
if (horse[9] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 10 won the race!!");
}
if (horse[0] > 75 && horse[1] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 2 tied!!");
}
if (horse[0] > 75 && horse[2] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 3 tied!!");
}
if (horse[0] > 75 && horse[3] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 4 tied!!");
}
if (horse[0] > 75 && horse[4] > 75 && horse[2] < 75 && horse[3] < 75 && horse[1] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 5 tied!!");
}
if (horse[0] > 75 && horse[5] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[1] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 6 tied!!");
}
if (horse[0] > 75 && horse[6] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[1] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 7 tied!!");
}
if (horse[0] > 75 && horse[7] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[1] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 8 tied!!");
}
if (horse[0] > 75 && horse[8] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[1] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 9 tied!!");
}
if (horse[0] > 75 && horse[9] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[1] < 75)
{
System.out.print(" Horse 1 and 10 tied!!");
}
if (horse[1] > 75 && horse[2] > 75 && horse[0] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 3 tied!!");
}
if (horse[1] > 75 && horse[3] > 75 && horse[2] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 4 tied!!");
}
if (horse[1] > 75 && horse[4] > 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 5 tied!!");
}
if (horse[1] > 75 && horse[5] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 6 tied!!");
}
if (horse[1] > 75 && horse[6] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 7 tied!!");
}
if (horse[1] > 75 && horse[7] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 8 tied!!");
}
if (horse[1] > 75 && horse[8] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 9 tied!!");
}
if (horse[1] > 75 && horse[9] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 2 and 10 tied!!");
}
if (horse[2] > 75 && horse[3] > 75 && horse[1] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 4 tied!!");
}
if (horse[2] > 75 && horse[4] > 75 && horse[1] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 5 tied!!");
}
if (horse[2] > 75 && horse[5] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 6 tied!!");
}
if (horse[2] > 75 && horse[6] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 7 tied!!");
}
if (horse[2] > 75 && horse[7] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 8 tied!!");
}
if (horse[2] > 75 && horse[8] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 9 tied!!");
}
if (horse[2] > 75 && horse[9] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 3 and 10 tied!!");
}
if (horse[3] > 75 && horse[4] > 75 && horse[2] < 75 && horse[1] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 5 tied!!");
}
if (horse[3] > 75 && horse[5] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 6 tied!!");
}
if (horse[3] > 75 && horse[6] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 7 tied!!");
}
if (horse[3] > 75 && horse[7] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[6] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 8 tied!!");
}
if (horse[3] > 75 && horse[8] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 9 tied!!");
}
if (horse[3] > 75 && horse[9] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 4 and 10 tied!!");
}
if (horse[4] > 75 && horse[5] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 6 tied!!");
}
if (horse[4] > 75 && horse[6] > 75 && horse[5] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 7 tied!!");
}
if (horse[4] > 75 && horse[7] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[5] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 8 tied!!");
}
if (horse[4] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[5] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 9 tied!!");
}
if (horse[4] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[5] < 75)
{
System.out.print(" Horse 5 and 10 tied!!");
}
if (horse[5] > 75 && horse[6] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 7 tied!!");
}
if (horse[5] > 75 && horse[7] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[6] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 8 tied!!");
}
if (horse[5] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 9 tied!!");
}
if (horse[5] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[8] < 75 && horse[6] < 75)
{
System.out.print(" Horse 6 and 10 tied!!");
}
if (horse[7] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 8 and 9 tied!!");
}
if (horse[7] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[8] < 75)
{
System.out.print(" Horse 8 and 10 tied!!");
}
if (horse[8] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75)
{
System.out.print(" Horse 9 and 10 tied!!");
}
if (horse[0] > 75 && x == 1 || horse[1] > 75 && x == 2 || horse[2] > 75 && x == 3 || horse[3] > 75 && x == 4 || horse[4] > 75 && x == 5 || horse[5] > 75 && x == 6 || horse[6] > 75 && x == 7 || horse[7] > 75 && x == 8 || horse[8] > 75 && x == 9 || horse[9] > 75 && x == 10)
{
a += y;
System.out.print("\n\n " + n + " has bet on the right horse! " + n + " won $" + a + "!!");
}
if (horse[0] < 75 && x == 1 || horse[1] < 75 && x == 2 || horse[2] < 75 && x == 3 || horse[3] < 75 && x == 4 || horse[4] < 75 && x == 5 || horse[5] < 75 && x == 6 || horse[6] < 75 && x == 7 || horse[7] < 75 && x == 8 || horse[8] < 75 && x == 9 || horse[9] < 75 && x == 10)
{
a -= y;
System.out.print("\n\n " + n + " has bet on the wrong horse! " + n + " lost $" + y + "!!");
}
if (x > 10 || x < 1)
{
System.out.print("\n\n " + n + " bet on a non-exsisting horse, so " + n + " lost $" + y + "!!");
}
if (horse[0] > 75 && p == 1 || horse[1] > 75 && p == 2 || horse[2] > 75 && p == 3 || horse[3] > 75 && p == 4 || horse[4] > 75 && p == 5 || horse[5] > 75 && p == 6 || horse[6] > 75 && p == 7 || horse[7] > 75 && p == 8 || horse[8] > 75 && p == 9 || horse[9] > 75 && p == 10)
{
a += d;
System.out.print("\n\n " + pt + " has bet on the right horse! " + pt + " won $" + z + "!!");
}
if (horse[0] < 75 && p == 1 || horse[1] < 75 && p == 2 || horse[2] < 75 && p == 3 || horse[3] < 75 && p == 4 || horse[4] < 75 && p == 5 || horse[5] < 75 && p == 6 || horse[6] < 75 && p == 7 || horse[7] < 75 && p == 8 || horse[8] < 75 && p == 9 || horse[9] < 75 && p == 10)
{
a -= d;
System.out.print("\n\n " + pt + " has bet on the wrong horse! " + pt + " lost $" + d + "!!");
}
if (p > 10)
{
System.out.print("\n\n " + pt + " bet on a non-exsisting horse, so " + pt + " lost $" + d + "!!");
}
}
public static void main(String[] args)
{
for (int lo = 0; lo < 10; lo++)
{
int ch;
Scanner choice;
fx1();
System.out.print("\n\n Nice Race!! If you want to play again, type 1 or type 2 to exit\n:");
choice = new Scanner(System.in);
ch = choice.nextInt();
if (ch == 1)
{
System.out.print("\n\nHorse Race 10 is restarting...Done\n\n\n");
lo = 2;
}
if (ch == 2)
{
System.out.print("\n\nHorse Race 10 is exiting... :(\n\n\nThanks for playing Horse Race 10!\n\n");
lo = 15;
}
}
}
}
also, is there another way to make the program handle ties without writing out all the different combinations?
thanks,
rabbit2345
01-22-2008, 03:46 PM
#2
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853
Rep:
Read the manpage for jar, or java, and there should be a description on how to do it.
Instead of doing each comparison by hand, why not use a general comparison template with two, nested FOR loops?
01-22-2008, 04:04 PM
#3
Member
Registered: Apr 2007
Location: SC
Distribution: Kubuntu 20.04 LTS
Posts: 378
Original Poster
Rep:
i'm not sure what you mean by a comparison template with 2 for loops, could you post a small example of that?
thanks
01-22-2008, 04:08 PM
#4
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
That sure is a lot of code.
For starters, you don't need to assign 0 to each element in your array since an array of ints will have 0s by default.
You can also reduce the last part by using loops or using Arrays methods binarySearch() and sort() and using Math method max().
Last edited by jay73; 01-22-2008 at 04:09 PM .
01-23-2008, 07:41 AM
#5
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853
Rep:
Quote:
Originally Posted by rabbit2345
i'm not sure what you mean by a comparison template with 2 for loops, could you post a small example of that?
What I simply mean is:
Code:
for (int x = 0; x < 10; x++) {
if (horse[x] > 75)
for (int y = (x + 1); y < 10; y++) {
// a quick, sorting algorithm to figure out
// which horse came first...
}
}
What I meant was to use two FOR loops to iterate through the array.
All times are GMT -5. The time now is 09:11 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News