Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You wouldn't replace it, no; you would have both. Java allows you to have two methods with the same name (called overloading a method), including a c'tor, so long as the parameter lists of the two methods are different.

Or you could just skip the default c'tor in CarsImpl, which would solve the whole issue entirely. Why did you want to have that there in the first place? It wasn't part of the assignment.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Write a constructor for Cars that doesn't take any arguments, and just put in some generic values as the default. Something like this:

public Cars() {
     this.item = 0;
     this.name = "Ford Probe";
     this.units = 1;
     this.price = 5000;
}

The default values are whatever values you consider to be a reasonable 'generic' or 'typical' car. In this case, there really isn't any really good choice for it, but any common one should do. Add this to Cars and it should allow you to call it in CarsImpl.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Simple: write a c'tor that takes no arguments and puts in default values to the instance variables.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Ah, this is what I explained earlier about default constructors. If you want a default c'tor for CarsImpl that calls a default c'tor for Cars, you need to add a default c'tor to Cars.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

And what errors is it giving now?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The first problem is because you are attempting to call a default constructor, but you didn't define one for the Cars class. Normally, if you don't define a c'tor, Java will define a default one for you; but if you define a non-default c'tor, then it doesn't generate the default c'tor, so there isn't one unless you explicitly implement it.

The second problem is because the type of the unitsInStock parameter for CarsImpl is long, while the Cars parameter total is an int, which is smaller. By trying to go from a long to an int, you are potentially losing data, hence the error. You have ther reverse problem with unitPrice and price. The solution is to change both so that they are both long and double, respectively:

public Cars (long number, String name, long total, double price)

and

CarsImpl(long productID, String productName, long unitsInStock, double unitPrice, String supplier)

Note that I made the ID numebr long as well.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, looking at the Cars class again, I can see you have the first two parameters reversed (and the last two as well);

public Cars (int number, String name, int total, double price)

so the call should in fact be

    super(productID, productName, unitsInStock, unitPrice);

I would recommend changing the CarsImpl c'tor to match as well:

CarsImpl(int productID, String productName, long unitsInStock, float unitPrice, String supplier)
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You are using different variable names in the super() call than you used in the parameter list for CarsImpl. Try the following:

super(productName, productID, unitPrice, unitsInStock);
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Could you post the error messages, please?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, then. There's no harm in it, I just was wondering.

At this point, you should have changed the class declaration for CarsInventoryRestock as I recommended, right? What was the result of that?

(And don't forget that the file name has to match the public class.)

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What is CarList for? It is basically just a copy of Cars with less documentation. Why is it included here?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually the real problem is that you're getting the parent-child relationship backwards: you want CarsInventoryRestock to be a sub-class of Cars, but right now you have it the other way around. It should look like:

public class CarsInventoryRestock extends Cars {

with the parent class being the one extended.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Since that's the class you're sub-classing, yes. You would have this class in one file, and your sub-class in another; both need to be declared as public classes.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

In order to create a sub-class of an existing class, you need to use the extends keyword and the name of the class being extended in the declaration of the new class.

class UsedCar extends Car {

    // ...

}

Furthermore, the parent class would have to have the methods which are to be overridden. In this case, it would be getUnitPrice(), though as Stultuske points out, as an assignment goes this example doesn't make much sense.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The problem is not in the numbers used, but in the size of the memnory being allocated. The type N is a pointer type, which means that it is likely to be one system word long (probably either 32 or 64 bits, assuming a common Intel or AMD CPU, though it could be 36 on a 32-bit PC with PAE enabled I guess). The structure you want to allocate memory for, however, consists of 4 ints, a double, and a pointer to the struct type, making at least 6 times as large as the amount of memory you are actually allocating.

The solution is to get rid of the typedef entirely, as you aren't using it anywhere else anyway, and just use

new = malloc(sizeof(struct PRIORITYQUEUE));

This will ensure that you have the right memory allocation.

Also, as I told you in my previous post, the del() function is flawed. You want to free new, not start, otherwise you'll lose the whole list and that could also cause the segfault.

I hope you are initializing start to NULL in your main() program. Just to be on the safe side, I would recommend adding a function init_pq() that just nulls out all the global variables used by these functions.

void init_pq()
{
    start = q = temp = new = NULL;
}    

Call that at the beginning of your program and it will ensure that you should get any initialization problems.

Finally, as I said before, this …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

To continue...

    new->info = item;
    new->priority = itprio;

The arrow is being used because new is a pointer right?

Yes. The 'arrow' is the member indirection operator; it allows you to access structure member elements from a pointer to that structure.

What if just new is a pointer and N wasn't a pointer? What about if N was a pointer and new wasn't a pointer? Would you still use a pointer in both cases?

This question doesn't make much sense to me. N isn't a pointer variable, it is a pointer type. Furthermore, since new was declared as type struct node * directly, not type N (even if they are in fact the same thing), the question of what N is isn't relevant.

    if ( start == NULL || itprio < start->priority )  

Was start set to NULL when it was declared at the top?

No, in fact as far as I can tell, none of the variables are being initialized to NULL explicitly. This is a Bad Thing, as the original programmer seems to be assuming that the compiler will zero out all the memory before it is used, which usually isn't the case. This is not the only place that bad practices are used; for example, the call to malloc() is incorrect, as I said earlier. also, the header file shouldn't be <malloc.h>; according to the standard, the dynamic memory functions are in <stdlib.h>. All in …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You would need to call isPrime() with two numbers, one the number you are checking and the other a number smaller than that but larger than it's square root.

I would reccomend changing the name of isPrime() to primeTest() and having a second function called isPrime(), which takes only one int as its argument. This would call primeTest() with some appropriate argument automatically, so that the main() function can pass only the number being tested as the argument to isPrime().

#include <iostream>
#include <cmath>

bool isPrime(int n);
bool primeTest(int n, int d); 

int main()
{
int number;
cout <<"Enter number >= 1";
cin >> number;
if(isPrime(number))
   {
     return 
      cout << "Yes";
      else
      return
      cout << "No";

    }
    return 0;
}

isPrime(int n)
{
    if (n < 2)
    {
       return false;
    }
    else if (n == 2)
    {
       return true;
    }
    else
    {
        return primeTest(n, (int) ceil(sqrt(n));
    }
}

bool primeTest(int n, int d)
{
    if(n<2)
        return false;
    if(d == 1)
        return true;
    else 
    {
        if(n % d == 0) 
            return false;
        else
            return isPrime(n, d - 1);
    }
}

The sqrt() function returns the square root of a number as a double, and the ceil() rounds the number up to the next integer value. the (int) is a cast to make the double an int.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

How exactly do structs in structs work? Do you need to do anything special with them?

What do you mean by 'special'? What you would do woith them would depend on what you intentions are. I know that sounds evasive, but it really is as much of an answer as I can give to such a vague question.

I think what you really want to know is, does the inner structure have to be a pointer?The answer to that again depends. In the general case, no, it doesn't - you can have a struct variable as an element of another struct:

struct POINT 
{
    int x, y;
};

struct VECTOR
{
    struct POINT start, end;
};

However, you'll note that these are individual elements, which are (relative to the structure) statically declared; if you want an element that is dynamically allocated, like a variable-length array or a linked list, the element would need to be a pointer to that data structure.

Also, any time a struct references its own type, it has to be via a pointer. Otherwise, the structure definition would be infinitely recursive.

Is this a form of a linked list?

Well, a linked data structure of some sort, yes. In this case, it does seem to be a list, but usually priority queues are more elaborate tree structures called heaps.

Which part of this is set to NULL? A lot of the comparisons later on are to NULL.

Well, …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I see you've changed to a different type of for() loop, which also changes how data is accessed. Change the references inside the loop back from products[model] to just product, so it is referring to the iterated object.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Most likely, these are just the values that happen to be in those memory addresses when the prgoram starts.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Were you able to solve the issue?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, first thing is, in C you can only declare variables at the beginning of the function, so I'm not sure why it is letting you put it there. The fact that it is inside the loop, however, means it is getting re-initialized each iteration, so it will always be zero.

Also, I assume that it is still printing out the rest of the line, correct?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Which part are you having trouble with?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You can't be serious. You expect us to help you cheat in an exam? Forget it.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

It is quite simple: first, you need an unsigned int variable as a counter, which should be initialized to zero. Alter your printf() statement to print this counter as a four-digit hex value followed by a a semi-colon and a space, followed by the string you are now printing. Finally, at the end of the printing loop, add NUM_CHARS to the counter.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The thing is, when computing a series like this, you can't simply jump to the nth iteration and get the right answer; you need to sum all the iterations before it to get the approximation. You want your for() loop to start at 1 and iterate by one, and have an if() that checks whether you've reached the one of the points you are to print the approximation out at.

Also, you want to declare pi outside of the loop; otherwise, it will get reset on each iteration.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Oh, and I just noticed that you dropped the semi-colon at the end of line 45.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Is the way I added '\n' and '\t' okay?

I'm not really sure, to be honest; it depends on whether you actually want to have some significance to them or not. In most (but not all) current languages, whitespace of all types (spaces, newlines, tabs) are treated as terminals, that is, they automatically end the current token. They generally aren't treated as tokens in and of themselves, or if they are, they are lumped together in a single token type. However, there are languages where whitespace is significant (e.g., Python), so treating them as tokens might be reasonable in those cases. It depends on the language being recognized.

As for your handling of the double-quote, that seems reasonable, from what I have seen of this so far. Without knowing more about your intended design I can't say much more.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Your casts are fine; the problem is that you haven't initialized the values of start.x and edges.x1[0] yet, so they have whatever garbage was in them before the program was run (or zeroes, at best, if the memory is getting cleared by the system before use).

BTW, did you see my answer to your previous question? I think you'd be able to better structure your data if you followed my earlier advice.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Ah, OK, I think I see the problem here. When you are working with arrays, you need to use the array index to indicate which element of the array you want, for example:

System.out.printf( "%s %d\n", "Product Number:", products[0].getProdNumber() );

Note the [0] part: that's the array index, which says, "get the zeroth element of the array" (array indices start at zero and got to n - 1 for a size n array).

OK, now here's the important part: you can have an int variable as the array index value as well. This is useful because you can take what I showed you with the for() loop and put your printf() lines inside the loop, such that the loop index becomes the array index. So if you have a for() loop:

    // get car information
    System.out.println("RGS New and Used Car Inventory Program");

    for(int model = 0; model < products.length; model++) 
        System.out.printf( "%s %d\n", "Product Number:", products[model].getProdNumber() );
        // put the rest of your printf()s here

    }

and do the same with thr rest of the lines, you can loop through the array to get them all.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'd have to see the code that's having the problem to be able to tell you the answer, I'm afraid. Without that, all I could do is guess. What symbol is it saying it can't find?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

A standard for() loop is used to repeat something a fixed number of times, with one variable - the index - changing on each iteration. It is similar to an if() or while(), except that the conditional has three parts: the initializer, the condition, and the iterator. An example looks like this:

 for( int i = 0; i < anArray.length; i++) {
      System.out.println(anArray[i]);
 }

How this works is, it first initializes the index, i, to zero. Then, it sees if i is less than the length of anArray; if it is, it prints anArray[i]. When the body of the loop is done, it adds one to i (that's what the i++ part does). It then goes back and checks of i < anArray.length, and if it is, it continues that way until i is no longer less than anArray.length.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You would presumably replace

    Cars product = new Cars(2479, "BMW M6", 45, 65000); 

with

    Cars[] products = new Cars[10];  // or however large the lot is supposed to be

You would then have to initialize each of the elements with the Cars() constructor:

   products[0] = new Cars(2479, "BMW M6", 45, 65000);
   products[1] = new Cars(2480, "Nissan Leaf", 23, 35000);
   products[2] = new Cars(2481, "Ford Focus", 17, 20000);

And so on like that. You could then put the part which you had on lines 15-19 in a for() loop to print out the information about the different car models.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Yes, we can, but we'd need to know what you have done already, or at least what you know how to do. We might need to see your code, or at least the part you are having problems with.

If you need to post part of tyour code, use the Code button on the top of the editing window to paste it it.

In general, for multiple items, you will need either an array, or a collection class such as an ArrayList or HashMap. For this purpose, where you presumably have items with names and a set of properties, a HashMap may be best, as you can then look up the item based on the name. A HashMap is a collection in which a key - for example, the name of the item - is mapped to a value - for example, the item object.

However, since this is an introductory project, I'm guessing they are looking for you to use an array, however. Arrays are the simplest of the compound data structures, being nothing more than a numbered series of elements of a given type. An array is declared like so:

 int[] anArray = new int[5];  // a five-element array of ints
 String[] anotherArray = new String[10] // a 10-element array of Strings

You can then access the elements from 0...n-1 like so:

 anArray[0] = 23;
 anotherArray[4] = "This is the fifth element of the array";

This is probably what you need to …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I would probably need to add a case for it in the switch in LexicalAnalysis.cpp, right? And add it to the state diagram?

If you want them as separate token types, then yes to both, though most languages treat all whitespace as a single token type.

The answer to the last part would depend on whether you are trying to represent the actual newline (which can be either a single byte or two bytes, depending on the operating system), or the escape representation of the newline. I assume you want the newline itself, in which case you would use the latter version.

You would only need to parse the escape form when handling character and string literals, and since this mini-language doesn't have any quoted literal token types, it isn't relevant. Not yet anyway - you'll want to keep it in mind when you start working on more elaborate language forms later.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, this is the C++ forum, not the C forum; you'll want to ask questions about C programming there. Second, all you've done is post your assignment; you haven't asked a question, or shown any indication of having done any of the work on the project yet. Daniweb rules state:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

It is forum policy that we will only provide assistance in solving problems, not answer the problems for you. No one here is going to hand you a homework solution gratis.

Oh, and you might want to use a more descriptive thread title, one explaining the help you need in more detail.

Now, then, what part of this do you need help with? If necessary, post those parts of your code you are having trouble with, using the Code button at the top of the editing window.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

No.

The rule at DaniWeb are simple:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

We can provide assistance, but we cannot do the work for you. You must solve the problem, if you are to learn from it. Otherwise, you are cheating, something we cannot condone, and even if we did, you would be likely to get caught. Do the work yourself; we've given you more than enough information to solve the problem.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Have you checked the C:\mypath\Release\ path?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You will want:

  • a variable that holds the character currently being printed
  • an outer for() loop to count the number of lines to print
  • an if() statement that flips the character being printed (hint: use the modulo (%) operator)
  • two inner for() loops, one that prints spaces, the second that prints the character line.
  • The total of the spaces and characters should be the same for each line, but on each successive line, you should add one to the number of characters and hence subtract one from for number of spaces.
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Sorry, I just realized I didn't answer your actual question; my apologies. As for whether you need to dynamically allocate the memory, in the case of a linked list, then answer is yes, both for the list itself and for any elements held by the list. So, if you use the approach I gave, earlier, for a given shape of size n, you would first need to allocate a SHAPE_LIST node, then allocate n FACE nodes. You would not need to explicitly allocate the VECTOR for each FACE, or the POINTs in each VECTOR, since those are values rather than pointers to values, but they would get allocated when the FACE is allocated.

I also forgot to explain why I changed the POINT elements from int to double. Mostly, it is because integer division is problematic when getting the vector sizes (which often have to be floating-point anyway, since they involve square roots), but also because not all common shapes are easily fit into integral positions. Using doubles just avoids certain problems, and while it can lead to other problems, it's generally easier to deal with in this case.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, I would recommend that, rather than having individual named structures as one-off types, that you define a POINT struct type and use that as the basis of your larger data structures:

struct POINT
{
    double x; 
    double y;
};

 /* a vector represents a directional line segment, that is,
  * a line segment going from one point to another with a
  * specific direction.  You can get the length of a vector by
  * the Pythagorean theorem: 
  * len = sqrt(square(end.x - start.x) + square(end.y - start.y))  
  */
struct VECTOR
{
    struct POINT start, end;
};

/* FACE is a doubly-linked ring structure of VECTORs
 * this means that each FACE points to the face before
 * it and the face after it, with the last face pointing
 * to the first one and vice versa.
 */
struct FACE
{
    struct VECTOR face;
    struct FACE *prev, *next; 
};

typedef SHAPE struct FACE*;    /* pointer to an arbitrary face */ 

struct SHAPE_LIST 
{
    SHAPE shape;
    struct SHAPE_LIST* next;
}

You will want functions for the following purposes: to create a vector from two points; to create a shape given a list of points (including remembering to close it); to compute the size of a given vector (I already gave you the formula for that above); to count the number of faces in a shape, given the shape (you would need to take the starting face and move around the shape until you reach it again); and to …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, you have some of the idea, but you seem confused about some aspects, such as parameteters and return values. Let me give some suggestions.

First off, your goal is to get the number of vowels in the function parameter, test. The parameter of a function is a value passed to it so that it can operate on that value. For example, in the function square() below,

double square(double x)
{
    return x * x;
}

the variable x is the formal parameter of square(). If I then have a function that calls square() with the argument 5,

n = square(5);

I would expect n to be assigned 25. I could also pass it a variable, like so:

m = square(n);

which would set m to 625. This is one of the main ideas behind functions: that you can use them with different arguments and get different results.

When testdriverb() calls countvowels() with the argument test (which has been set to the string "Programing language IS FUN to learn: "), it sets the value of the parameter test in countvowels() to that string.

Note that the name of the argument doesn't have to match the name of the parameter, and in fact the argument doesn't even have to be a variable at all (in most cases). If you look again at my earlier code, you'll see that I used a literal as the argument to square(), for example. You could have called the variable …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I assume that the OP is referring to XMBC Media Center, but I don't know enough about it myself to make sense out of the question, either. I would suggest that the OP seek help on the XMBC forums directly, as there presumably would be people familiar with the program in question.

I will recommend one other thing, as a general principle in Python programming. Rather than having the extended if-elif/else statement you have from lines 22-53, it would be better structured and more Pythonic to make a lookup table consisting of a range and a value. A simple representation might be a dictionary where the key is a tuple pairing the startpoint and endpoint of the length range, and the the second value is the width. You would then have a function to extract the values from the dictionary as needed. Something like this should work:

def get_program_width(program_length):
    width_map = {(10, 60): 342.5, (60, 90): 690, (90, 105) : 1050, 
                 (105, 120): 1400, (120, 150): 1750, (150, 180): 2100, 
                 (180, 210): 2450, (210, 240): 2800, (240, 270): 3150, 
                 (270, 300): 3500, (300, 330): 3850, (330, 360): 4200, 
                 (360, 390): 3250, (390, 420): 4550, (420, 450): 4900, 
                 (450, 480): 5250}

    keylist = width_map.keys()

    for key in keylist:
        if program_length in range(key[0] + 1, key[1] + 1):
            return width_map[key]
    return 0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually, reliability is not the real issue with analog computers; indeed, they can be much more reliable at times, as they don't have issues of round-off errors and so forth that are inherent in digital computers. Analog devices have the advantage of being continous rather than discrete, and thus are better models for certain problems.

Reliability can be an issue, of course, in that most analog devices are mechanical, and subject to wear. However, well-machined parts mean that an analog computer is unlikely to wear out within it's useful lifespan.

The real limits with analog computers is that they are always special-purpose devices; no practical Turing-equivalent analog computers have ever been designed. This isn't to say it isn't possible, but given the advantages of digital computing and the experience gained with it over the past 60 years, it is unlikely that any general-purpose analog devices will be developed. The only reason to use an analog computer today is if something needs to be modelled very accurately in a continuous manner, and since current digital devices provide very high resolution (if still discrete) accuracy, that almost never arises.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Except that SQLite is a completely different database system.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually, you've misunderstood what the term 'SQL injection' means, and fortunately for you, your script doesn't involve any. All your code does is open a connection to a MySQL database server and create a cursor, the basic steps interacting with a database.

SQL injection is a (bad) way of building a SQLquery string, in which user input is inserted directly to a text query string and then executed:

name = raw_input("What is your name?")
cur.execute("SELECT * FROM Students WHERE Name = '%s';" % name)

The reason this is a bad idea is the same reason while it was a bad idea to use input() in Python 2.x: because the user could put anything into the input, not just their name, and the 'data' will get executed along with the query. For example, if I entered Robert'; DROP TABLE Students; --, the final query string would read

"SELECT * FROM Students WHERE Name = 'Robert'; DROP TABLE Students; --';"

which would wreak havoc on the database.

The way to avoid SQL injection is to use a prepared statement, which is a feature of the database that vetts the data automatically for you, making the above scenario less likely.

name = raw_input("What is your name?")
cur.execute("SELECT * FROM Students WHERE Name = %s;", (name))     

This may seem like a trivial difference, but when using the prepared statement, the database checks the validity of the interpolated data, making sure that the cannot execute …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Then that would be your first step, wouldn't it? Writing out even a basic skeleton on a class and a main() function would at least give us code to discuss.

We will not write your program for you. Not only does it do you no good for us to simply hand you the code, it is against Daniweb policy. One of the forum rules states:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

We cannot help you unless you do this. We are here to give advice, not provide free homework.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Where you have it now (lines 21-34) is actually workable. The implementation has several problems with it as it stands, but you could leave it right where it is. However, that's not what you would usually do.

Has your instructor (or textbook) explained about writing separate methods other than Main() yet?

The usual solution to this is to write a bubblesort() method and pass the data to that. If you have covered methods already, then the solution is to write the bubblesort() method after the end of the Main() method, and call it in Main().

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I will give one piece of advice, but I don't know if it will make sense to you yet. Anyway, here it goes:

When getting numbers from standard input, the natural inclination is to use scanf() directly. I don't recommend that, as it can have unforeseen issues with the newline marker, a character the keyboard issues when the Enter key is hit. When something is read in from the console to stdin, the whole line of input is temporarily saved in a memory space called a buffer. If you use scanf() to read the numbers in, the newline will still be there in the buffer, meaning that the next time you try to read something from the stdin, it will read the newline first, and cause problems as it is expecting some other kind of data.

The solution is to read the data from stdin as a line of text (that is, and array of char) using fgets(), then convert that to an int using the formatted string scanning function, sscanf() (note the extra 's'). This a well-known trick for avoiding the buffered newline problem. You would do something like this:

#define BUF_SIZE 256
/* .. later ... */

char buffer[BUF_SIZE];
int input_a;

/* even later ... */

fgets(buffer, BUF_SIZE - 1, stdin);
sscanf(buffer, "%d", &input_a);

This is just a quick sketch of how you would use it; the details will be up to you.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, you should know before anything else that no one here is going to do the work for you. It is Daniweb policy that we assist you in solving your problem, but that we not solve the problem directly by providing code. It doesn't sound like that is what youu are after, but it still needs to be said.

Second, I don't know if anyone here is going to be familiar enough with the specific area of expertise needed. I hope there is, but I won't promise it. Most of the people here are software engineers rather than mathematicians or physicists.

Third, the question is ambiguous, as there is no single Levi-Civita tensor. I am no mathematician, but from what is said on the subject on Wikipedia, there are invariant, co-variant and contra-variant tensor fields of this type, and while thelatter two at least can be inter-converted, they are different enough that you would need to know which type of Levi-Civita tensor field you are working with.

My best advice is to start by developing a general matrix class, which could be used as the starting point for the actual tensor field data structure. Once you can abstract away the matrix, you can handle it in a way suitable for applying the appropriate functions to the determinant of the matrix.