Click here to Skip to main content
15,913,055 members
Home / Discussions / Java
   

Java

 
QuestionRe: reading ipaddress from xml file Pin
Richard MacCutchan20-Feb-14 23:29
mveRichard MacCutchan20-Feb-14 23:29 
AnswerRe: reading ipaddress from xml file Pin
Member 1003910920-Feb-14 23:37
Member 1003910920-Feb-14 23:37 
SuggestionRe: reading ipaddress from xml file Pin
Richard MacCutchan20-Feb-14 23:42
mveRichard MacCutchan20-Feb-14 23:42 
GeneralRe: reading ipaddress from xml file Pin
Member 1003910920-Feb-14 23:47
Member 1003910920-Feb-14 23:47 
GeneralRe: reading ipaddress from xml file Pin
Richard MacCutchan21-Feb-14 0:08
mveRichard MacCutchan21-Feb-14 0:08 
GeneralRe: reading ipaddress from xml file Pin
Member 1003910921-Feb-14 0:11
Member 1003910921-Feb-14 0:11 
GeneralRe: reading ipaddress from xml file Pin
Richard MacCutchan21-Feb-14 0:33
mveRichard MacCutchan21-Feb-14 0:33 
GeneralRe: reading ipaddress from xml file Pin
Member 1003910921-Feb-14 0:41
Member 1003910921-Feb-14 0:41 
AnswerRe: reading ipaddress from xml file Pin
chronodekar21-Feb-14 2:08
chronodekar21-Feb-14 2:08 
GeneralRe: reading ipaddress from xml file Pin
Richard MacCutchan21-Feb-14 2:22
mveRichard MacCutchan21-Feb-14 2:22 
Questionhow to profile a java application(beginner) ? Pin
chronodekar18-Feb-14 6:28
chronodekar18-Feb-14 6:28 
AnswerRe: how to profile a java application(beginner) ? Pin
Richard MacCutchan18-Feb-14 22:32
mveRichard MacCutchan18-Feb-14 22:32 
GeneralRe: how to profile a java application(beginner) ? Pin
chronodekar19-Feb-14 4:05
chronodekar19-Feb-14 4:05 
GeneralRe: how to profile a java application(beginner) ? Pin
Richard MacCutchan19-Feb-14 4:22
mveRichard MacCutchan19-Feb-14 4:22 
QuestionPattern Pin
V$ethi14-Feb-14 0:12
V$ethi14-Feb-14 0:12 
AnswerRe: Pattern Pin
Richard MacCutchan14-Feb-14 0:47
mveRichard MacCutchan14-Feb-14 0:47 
GeneralRe: Pattern Pin
V$ethi15-Feb-14 5:01
V$ethi15-Feb-14 5:01 
QuestionRe: Pattern Pin
Richard MacCutchan15-Feb-14 6:03
mveRichard MacCutchan15-Feb-14 6:03 
AnswerRe: Pattern Pin
V$ethi15-Feb-14 16:25
V$ethi15-Feb-14 16:25 
GeneralRe: Pattern Pin
Richard MacCutchan15-Feb-14 21:11
mveRichard MacCutchan15-Feb-14 21:11 
GeneralRe: Pattern Pin
chronodekar17-Feb-14 21:18
chronodekar17-Feb-14 21:18 
GeneralRe: Pattern Pin
Richard MacCutchan17-Feb-14 21:30
mveRichard MacCutchan17-Feb-14 21:30 
GeneralRe: Pattern Pin
chronodekar18-Feb-14 3:40
chronodekar18-Feb-14 3:40 
There might be a more efficient way of doing it, but here's my thinking.

1. Arrange all the numbers in descending order. Make note of the largest one ( = A). Also store the numbers in an array ( = ARRAY)
2. Count the number of inputs ( = B).
3. Visualize the output in the form of a rectangle - you need to draw (with ASCII) a rectangle whose height is A and width B. Alternatively, you need to print A no. of lines with B characters.

Now we come to implementation. In pseudo-code;
Java
for (i = A ; i>0; i--) 
{
    for (j = 0; j<B; j++)
    {
        if (ARRAY(j) > i)
            print("*");
        else
            print("O");
    }
    print("\n");    
}


I think that should do it. Any edge case I missed?

-chronodekar
AnswerRe: Pattern Pin
jschell14-Feb-14 10:30
jschell14-Feb-14 10:30 
GeneralRe: Pattern Pin
V$ethi15-Feb-14 5:07
V$ethi15-Feb-14 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.