Xiaonb
BAN USERB.Eng;
M.Sc
nuts financial engineer
nuts java programmer
public static void main(String[] args) {
String [] inputA = {"1","3","5","7","9"};
String [] inputB = {"2","4","8","10","11","15",null,null,null,null,null};
int[] inputC = new int [inputB.length];
int[] output = new int[inputB.length];
int j = 0, k = 0;
for(int i=0; i<=inputB.length-1; i++){
if (inputB[i] == null) {
inputC[i] = Integer.parseInt(inputA[j]);
j++;
}
else{
inputC[i] = Integer.parseInt(inputB[k]);
k++;
}
}
output = mergeSort(inputC);
System.out.println(Arrays.toString(output));
}
import java.util.Arrays;
public class CareerUp_ReverseInt {
public static void main(String[] args) {
int[] input = {2,3,5,6,6,12,4,2};
int[] output = new int[input.length];
int j = 0;
for(int k=input.length-1; k>=0 ; k--){
int temp = 0;
for(int i=input.length-1 ; i>=k ; i--){
temp = temp + input[i];
}
output[j] = temp;
j++;
}
System.out.println(Arrays.toString(output));
}
}
import java.util.Arrays;
public class CareerUp_ArrayIndex {
public static void main(String[] args) {
process();
}
public static void process() {
int[] price = {1,3,0,8,12, 0, 4, 0,7};
int[] _price = new int[price.length];
int j = price.length-1;
int k = 0;
for (int i=0;i<price.length;i++){
if (price[i] != 0){
_price[k] = price[i];
k++;
}
if (price[i] == 0){
_price[j] = price[i];
j--;
}
}
System.out.println(Arrays.toString(_price));
}
}
The following is my code:
- Xiaonb August 13, 2012any bug/error exist?
public class construct_polynomial {
public static void polynomial(Vector<Double> v, double x){
double sum = 0.0;
for(int i = 0 ; i<=v.size()-1 ; i++){
sum += v.elementAt(i) * Math.pow(x,i);
}
System.out.println(sum);
}
}