Ergasia Java Error

Κώδικας, πληροφορίες, ερωτήσεις και απαντήσεις σχετικές με την JavaScript.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
vage1987
Δημοσιεύσεις: 1
Εγγραφή: 01 Ιουν 2010 23:26

Ergasia Java Error

Δημοσίευση από vage1987 » 01 Ιουν 2010 23:38

Kalispera....
Tha ithela tin voithia sas gian ena provlima pou exo se ena programa java..
To programa molis pao na ftiajo tin class(javac Bookstore2[1].java) mou vgazi Error
sto proto public class Bookstore2 {
^

Efxaristo ek ton proteron
to programa einai afto:


import java.util.Arrays;
import java.io.*;
import java.io.IOException;

public class Bookstore2 {


public Bookstore2() {
}

public class client{
int Code;
int Age;
int Books;
int Total;
int Deficit;

}


// A*************************************************************
public static void mergeSort_srt(int array[],int lo, int n){
int low = lo;
int high = n;
if (low >= high) {
return;
}

int middle = (low + high) / 2;
mergeSort_srt(array, low, middle);
mergeSort_srt(array, middle + 1, high);
int end_low = middle;
int start_high = middle + 1;
while ((lo <= end_low) && (start_high <= high)) {
if (array[low] < array[start_high]) {
low++;
} else {
int Temp = array[start_high];
for (int k = start_high- 1; k >= low; k--) {
array[k+1] = array[k];
}
array[low] = Temp;
low++;
end_low++;
start_high++;
}
}
}

public void Merge(client[] clients){
int i;
int BooksArray[] =new int[1000];
int DeficitArray[] = new int[1000];
//Dhmiourgia pinakwn me ton arithmo twn vivliwn kai to xrewstiko upoloipo antistoixa
for(i=0;i<1000;i++)
{
BooksArray=clients.Books;
DeficitArray=clients.Deficit;
}
mergeSort_srt(BooksArray,0,BooksArray.length-1);
mergeSort_srt(DeficitArray,0,DeficitArray.length-1);

}
//B****************************************************

public void quicksort (int[] a, int lo, int hi)
{
// to lo einai o mikroteros deikths kai to hi einai o megaluteros deikths
// ths perioxhs tou pinaka pou tha taxinomithei
int i=lo, j=hi, h;

// stoixeio sugkrishs x
int x=a[(lo+hi)/2];

// partition
do
{
while (a<x) i++;
while (a[j]>x) j--;
if (i<=j)
{
h=a; a=a[j]; a[j]=h;
i++; j--;
}
} while (i<=j);

// Anadromikothta
if (lo<j) quicksort(a, lo, j);
if (i<hi) quicksort(a, i, hi);
}

public void QuickSort(client[] clients){
int i;
int CodesArray[] =new int[1000];

//Dhmiourgia pinakwn me tous kwdikous twn pelatwn

for(i=0;i<1000;i++)
{
CodesArray=clients.Code;
}
quicksort(CodesArray,0,CodesArray.length-1);
}

//C************************************************************

public int interpolationSearch(int[] sortedArray, int toFind){
// Returns index of toFind in sortedArray, or -1 if not found
int low = 0;
int high = sortedArray.length - 1;
int mid;

while (sortedArray[low] <= toFind && sortedArray[high] >= toFind) {
mid = low + ((toFind - sortedArray[low]) * (high - low)) / (sortedArray[high] - sortedArray[low]);

if (sortedArray[mid] < toFind)
low = mid + 1;
else if (sortedArray[mid] > toFind) // Repetition of the comparison code is forced by syntax limitations.
high = mid - 1;
else
return mid;
}

if (sortedArray[low] == toFind)
return low;
else
return -1; // Not found
}

public void inter_search(client[] clients){
int i;
int CodesArray[] =new int[1000];
int AgesArray[]=new int[1000];
String input="";
int flag;
int toFind;

BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
for(i=0;i<1000;i++)
{
AgesArray=clients[i].Age;
CodesArray[i]=clients[i].Code;
}
System.out.println("Grapse 1 gia anazhthsh me vash ton kwdiko kai 2 gia anazhthsh me vash thn hlikia");
input = bufferedreader.readLine();
flag = Integer.parseInt(input);
if(flag==1)
{
input = bufferedreader.readLine();
toFind = Integer.parseInt(input);

System.out.println(interpolationSearch(CodesArray, toFind));
}
else{
input = bufferedreader.readLine();
toFind = Integer.parseInt(input);
System.out.println(interpolationSearch(AgesArray, toFind));
}
}

//D****************************************
static class Node {
Node left;

Node right;

int value;

public Node(int value) {
this.value = value;
}
}
public void insert(Node node, int value) {
if (value < node.value) {
if (node.left != null) {
insert(node.left, value);
} else {

node.left = new Node(value);
}
} else if (value > node.value) {
if (node.right != null) {
insert(node.right, value);
} else {

node.right = new Node(value);
}
}
}

public void printInOrder(Node node) {
if (node != null) {
printInOrder(node.left);

printInOrder(node.right);
}
}
public void DentroAnazhthshs(client[] clients) {
// build the simple tree from chapter 11.
int i;
int CodesArray[] =new int[1000];

//Dhmiourgia pinakwn me tous kwdikous twn pelatwn

for(i=0;i<1000;i++)
{
CodesArray[i]=clients[i].Code;
}

Node root = new Node(CodesArray[0]);
for(i=1;i<1000;i++){
insert(root,CodesArray[i]);
}

System.out.println("Emfanish timwn dentrou me th seira");
printInOrder(root);

}




}

Απάντηση

Επιστροφή στο “JavaScript και Frameworks”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 2 επισκέπτες