public static void main(String[] args)
{    
    int[] out;
    for (i=0;i<args.length;i++)
        {  
           String number_string=new String();
           if(args[i].equals("-i"))
             {  
                if(i+1<args.length)
                  { 
                    i++;
                    number_string=args[i];
                  }
                StringTokenizer number=new String Tokenizer (number_string,',');
                int chip_number=number_string.replaceAll("[^,]","").length();
                chip_number++;
                int k=0;
                while (number.hasMoretokens())
                   { 
                     number_int[k]=Integer.parseInt(number.nextToken());
                     k++;
                   }
             }
        }
    for(i=chip_number-1;i>=0;i--)
      {
         for(j=0;j<number_int[i];j++)
           {
              out[j]=j;
           }
         //should be a double array here?
      }

}

hi all,
the situation is, if:
input:-i 3,2,4,5
the output should be:
0,0,0,0
1,1,1,1
2, ,2,2
, ,3,3
, , ,4

i start from the end of input and put the list 0->(number_int-1)

my problem is, can i use double array to get the result as the expected output?
or any other way should i do?

Recommended Answers

All 7 Replies

Can you explain how you create the output from the input?

Can you explain how you create the output from the input?

firstly im sorry i coded it wrong.duplicate index variable without int.sori for the mistake.lets change this

for(int m=chip_number-1;m>=0;m--)
  {
      for(j=0;j<number_int[m];j++)
        {
          out[j]=j;
        }
     //should be a double array here?
  }

from the code, i convert string to int.lets say the input is 3,so the output should be 0,1,2.this is not the problem because i coded it already.and this output i pass to an array out[j].i want to combine the data in out[j] so can be like expected output.thats why i asked can i use double array to that solution.
because at last i want to view the output like this;

0,0,0,0
1,1,1,1
,2,2,2

row by row.

What is the code you just posted supposed to do?
It assigns the index's value to the array at that index. What is the number_int array supposed to hold?

What is the code you just posted supposed to do?
It assigns the index's value to the array at that index. What is the number_int array supposed to hold?

number_int is just convert the string to int.user input is like this eg: 3,2,4,5...this input in a string then must be convert to int because i want to use the int number from the input.and of cos separate the input using tokenizer.
so,if see from the input 3,2,4,5 .actually there are 4 different input which is 3 and 2 and 4 and 5.so, the code that i just corrected is to get the data from each of the input.example 3: the data is 0,1,2

Sorry, I still have no idea what the program is supposed to do.

Sorry, I still have no idea what the program is supposed to do.

its ok...my bad.but ive solved the problem...thanks

ive solved it.just declare as usual

int[][] TestCase_Store = new int[count][value.length];

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.