int decode(int correct_mode, int *errs, unsigned long *cw) <br>
/* This function decodes codeword *cw in one of two modes. If correct_mode <br>
is nonzero, error correction is attempted, with *errs set to the number of<br>
bits corrected, and returning 0 if no errors exist, or 1 if parity errors <br>
exist. If correct_mode is zero, error detection is performed on *cw, <br>
returning 0 if no errors exist, 1 if an overall parity error exists, and <br>
2 if a codeword error exists. */ <br>
{ <br>
unsigned long parity_bit; <br><br>
if (correct_mode) /* correct errors */ <br>
{ <br>
parity_bit=*cw & 0x800000l; /* save parity bit */ <br>
*cw&=~0x800000l; /* remove parity bit for correction */<br><br>
*cw=correct(*cw, errs); /* correct up to three bits */ <br>
*cw|=parity_bit; /* restore parity bit */ <br><br>
/* check for 4 bit errors */ <br>
if (parity(*cw)) /* odd parity is an error */ <br>
return(1); <br>
return(0); /* no errors */ <br>
} <br>
else /* detect errors only */ <br>
{ <br>
*errs=0; <br>
if (parity(*cw)) /* odd parity is an error */ <br>
{ <br>
*errs=1; <br>
return(1); <br>
} <br>
if (syndrome(*cw)) <br>
{ <br>
*errs=1; <br>
return(2); <br>
} <br>
else <br>
return(0); /* no errors */ <br>
} <br>
} /* decode */ <br>
int decode(int correct_mode, int *errs, unsigned long *cw)
public int[] decode(int correct_mode, int errs, int cw);
int[] arr = int long[3];
arr[1]=2;
arr[1]=errs;
arr[2]=cs;
return arr;
return 0 и return 1 аналогично.int[] arr = decode(correct_mode, errs, cw);
result = arr[0];
errs = arr[1];
cw = arr[2];
Вроде бы ничего не забыл.public class ByRef<T> {
private T ref;
public ByRef(T ref) {
set(ref);
}
public T get() {
return this.ref;
}
public void set(T ref) {
this.ref = ref;
}
}
public class Foo {
public static void bar(ByRef<String> value) {
value.set("Good bye!");
}
public static void main(String... args) {
ByRef<String> message = new ByRef<String>("Hello!");
System.out.println("Before call: " + message.get());
bar(message);
System.out.println("After call: " + message.get());
}
}
int decode(int corect_mode, ref int errs, ref long cw)
{
//остальной код
//...
else {
errs = 0;
if(parity(cw))
{
errs = 1;
return 0
}
//Остальной код
}
}