How to get this output?

I need to get the following output
1
2 3
4 5 6
7 8 9 10
This is my code so far
        int j=0;
        int y = 0;
        for (int i = 1; i <= 4; i++) {
            if( i == y) i += 1;
            for (j = 0; j < i; j++) {
                y = i+j;
                System.out.print(y);
            System.out.println("");
        }And this is the output I get
1
23
4567
Any help?

I don't understand the logic.
what is this for?
if( i == y) i += 1;by increasing i more than once per loop (including the i++ at for() part), you are decreasing the number of loops. That is why your output is only 3 lines.
Message was edited by:
Icycool

Similar Messages

  • How to get this output using sql query?

    Hi,
      How to get this output using sql query?
    Sno Name Age ADD Result
    1 Anil 23 delhi Pass
    2 Shruti 25 bangalor Pass
    3 Arun 21 delhi fail
    4 Sonu 23 pune Pass
    5 Roji 26 hydrabad fail
    6 Anil 28 delhi pass
    Output
    Sno Name Age ADD Result
    1 Anil 23 delhi pass
    28 delhi pass

    Hi Vamshi,
    Your query is not pretty clear.
    write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
    Regards,
    Kannan

  • How to get this output format in ALV report

    Hi.
    Can any one pls let me know how to get the following output format in ALV report.Following are the outputfields
    companycode   location     position     approver
    300    800       01    watson
    null   null        03     candy
    null   null        04     smith
    null   null        05     michael
    one empty line after this again
    300     800     01     ryant
    null      null    02     gyan
    null      null    03     fermi
    null      null    04     ogata
    *Note: Null     indicates  empty space .( i.e I need to get empty space in  output where ever null is there.)
            Thanks in advance.
    Kind Regards,
    samiulla.

    hi,
    u can use 'REUSE_ALV_LIST_DISPLAY'
                           or
    'REUSE_ALV_GRID_DISPLAY'  function modules.
    SAMPLE CODE :
    *& Report  Y101982CHD
    *                         TABLES
    TABLES: vbak.    " standard table
    *                           Type Pools                                 *
    TYPE-POOLS: slis.
    *                     Global Structure Definitions                     *
    *-- Structure to hold data from table CE1MCK2
    TYPES: BEGIN OF tp_itab1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           werks LIKE vbap-werks,
           lgort LIKE vbap-lgort,
           END OF tp_itab1.
    *-- Data Declaration
    DATA: t_itab1 TYPE TABLE OF tp_itab1.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
    *                    Selection  Screen                                 *
    *--Sales document-block
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF  BLOCK b1.
    *--Display option - block
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: alv_list RADIOBUTTON GROUP g1,
                alv_grid RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF  BLOCK b2.
    *file download - block
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: topc AS CHECKBOX,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF  BLOCK b3.
    *                      Initialization.                                *
    *                      At Selection Screen                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
        EXPORTING
          dynpfield_filename = 'P_FILE'
          dyname             = sy-cprog
          dynumb             = sy-dynnr
          filetype           = 'P'      "P-->Physical
          location           = 'P'     "P Presentation Srever
          server             = space.
    AT SELECTION-SCREEN ON s_vbeln.
      PERFORM vbeln_validate.
    *                           Start Of Selection                         *
    START-OF-SELECTION.
    *-- Fetching all the required data into the internal table
      PERFORM select_data.
    *                           End Of Selection                           *
    END-OF-SELECTION.
      IF t_itab1[] IS NOT INITIAL.
        IF topc IS NOT INITIAL.
          PERFORM download.
          MESSAGE 'Data Download Completed' TYPE 'S'.
        ENDIF.
        PERFORM display.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    *                           Top Of Page Event                          *
    TOP-OF-PAGE.
    *& Form           :      select_data
    * Description     : Fetching all the data into the internal tables
    *  parameters    :  none
    FORM select_data .
      SELECT vbeln
         posnr
         werks
         lgort
         INTO CORRESPONDING  FIELDS OF TABLE t_itab1
         FROM vbap
         WHERE  vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " select_data
    *& Form        : display
    *  decription  : to display data in given format
    * parameters   :  none
    FORM display .
      IF alv_list = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                               USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
       'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
       'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
       'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
       'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
    **        it_events                = t_alv_events[]*
            *it_fieldcat              = i_fieldcat[]*
          *TABLES*
            *t_outtab                 = t_itab1[]*
          *EXCEPTIONS*
            *program_error            = 1*
            *OTHERS                   = 2.*
        *IF sy-subrc <> 0.*
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
    **         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
        *ENDIF.*
      ENDIF.
      IF alv_grid = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                                 USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
         'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
         'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
         'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
         'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
            *it_fieldcat              = i_fieldcat*
          *TABLES*
            *t_outtab                 = t_itab1[]*
        *EXCEPTIONS*
       *program_error                     = 1*
       *OTHERS                            = 2.*
        *IF sy-subrc <> 0.*
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
    **         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
        *ENDIF.*
      *ENDIF.*
    ENDFORM.                    " display
    *& Form        : vbeln_validate
    *  description : to validate sales document number
    * parameters   :  none
    FORM vbeln_validate .
      DATA: l_vbeln TYPE vbak-vbeln.
      SELECT SINGLE vbeln
        FROM vbak
        INTO l_vbeln
        WHERE vbeln IN s_vbeln.
      IF sy-subrc NE 0.
        MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " vbeln_validate
    *& Form       :build_fieldcat
    * Description : This routine fills field-catalogue
    *  Prameters  : none
    FORM build_fieldcat TABLES  fpt_fieldcat TYPE slis_t_fieldcat_alv
                        USING   fp_field     TYPE slis_fieldname
                                fp_table     TYPE slis_tabname
                                fp_length    TYPE dd03p-outputlen
                                fp_ref_tab   TYPE dd03p-tabname
                                fp_ref_fld   TYPE dd03p-fieldname
                                fp_seltext   TYPE dd03p-scrtext_l
                                fp_col_pos   TYPE sy-cucol.
    *-- Local data declaration
      DATA:   wl_fieldcat TYPE slis_fieldcat_alv.
    *-- Clear WorkArea
      wl_fieldcat-fieldname       = fp_field.
      wl_fieldcat-tabname         = fp_table.
      wl_fieldcat-outputlen       = fp_length.
      wl_fieldcat-ref_tabname     = fp_ref_tab.
      wl_fieldcat-ref_fieldname   = fp_ref_fld.
      wl_fieldcat-seltext_l       = fp_seltext.
      wl_fieldcat-col_pos         = fp_col_pos.
    *-- Update Field Catalog Table
      APPEND wl_fieldcat  TO  fpt_fieldcat.
    ENDFORM.                    "build_fieldcat
    *& Form        : download
    *  description : To Download The Data
    *  Parameters  :  none
    FORM download .
      DATA: l_file TYPE string.
      l_file = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
          filetype                = 'ASC'
        TABLES
          data_tab                = t_itab1
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " download
    HOPE IT WILL HELP YOU
    REGARDS
    RAHUL SHARMA

  • One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?

    How to get the below output using REGULAR EXPRESSIONS??
    SQL> ed
    Wrote file afiedt.buf
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    Table created.
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    1 row created.
    SQL> SELECT * FROM cus___addresses;
    FULL_ADDRESS
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AM

    Hi,
    user12240205 wrote:
    ... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
    Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
    Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
    '.*' means "0 or more of any character".
    '\D*' means "0 or more non-digits".
    The whole expression, '.*(\d{5})\D*' means:
    a. 0 or more characters (any characters)
    b. 5 digits
    c. 0 or more non-digits.
    '\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
    So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone."

  • How to print this output. (Array)

    Hi all. I have two String array:
    String[] a = { "a", "b", "c", "d", "e" };
    String[] b = { "b", "d" };
    I want to print this two array into this output:
    Output:
    a
    bb
    c
    dd
    e
    Anybody can help me how to get this output. I have try with a for loop, but it's not working.

    try this,
    boolean found=false;
    for(int i=0; i<a.length;i++)
             found=false;
             for(int j=0;j<b.length;j++)
                     if(a.equals(b[j])
    found=true;
    if(found==true)
    System.out.println(a[i]+a[i]);
    else
    System.out.println(a[i]);

  • How to generate this output?URGENT

    how to generate using DOM or SAX to get this output?
    <project>
    <process name = " Process1 " >
    </project>
    i am stuck here ... may i know how to continued coding from here.. must add in wat ? can any one tell me thank....
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import org.w3c.dom.DOMException;
    import java.io.*;
    import java.util.*;
    public class TestVector
         private Vector m_vProcess;
         String strProjectName;
         public static void main(String[] args)
              TestVector pThis = new TestVector();
              pThis -> WriteToXML(m_vProcess);
         public void TestVector {
              strProjectName ="Project1";
              m_vProcess = new Vector();               
              m_vProcess.add("Process1");
              m_vProcess.add("Process2");
         public void WriteToXML(Vector vProcess)
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = facory.newDocumentBuilder();
              Document builder = builder.parse("Project.xml");
              Node rootNode = document.getDocumentElement();
              NodeList list = document.getElementsByTagName("Project");
    // Loop through the list.
              for (int i=0; i < list.getLength(); i++) {
              thisProjectNode = list.item(i);
              Node thisName1Node = thisProjectNode.getFirstChild();
              if (thisName1Node == null) continue;
              if (thisName1Node.getFirstChild() == null) continue;
              if (! thisName1Node.getFirstChild() instanceof
    org.w3c.dom.Text) continue;
              String data = thisName1Node.getFirstChild().getNodeValue();
              if (! data.equals("Process1")) continue;
    //We're at the Mocha Java node. Create and insert the new
    //element.
              Node newCoffeeNode = document.createElement("Project");
              Node newName1Node = document.createElement("Process");
              Text tnNode = document.createTextNode("Process1");
              newName1Node.appendChild(tnNode);
              Node newName2Node = document.createElement("Process");
              Text tpNode = document.createTextNode("Process2");
              newName2Node.appendChild(tpNode);
              newProjectNode.appendChild(newName1Node);
              newProjectNode.appendChild(newName2Node);
              rootNode.insertBefore(newProjectNode, thisProjectNode);
              break;

    i am not good in programming..wat ever i read b4 ,i wlll forget easily ..and y the output nv come out after i type these...
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import org.w3c.dom.DOMException;
    import java.io.*;
    import java.util.*;
    public class TestVector
         private Vector m_vProcess;
         String strProjectName;
         public static void main(String[] args)
              TestVector pThis = new TestVector();
              pThis -> WriteToXML(m_vProcess);
         public void TestVector {
              strProjectName ="Project1";
              m_vProcess = new Vector();               
              m_vProcess.add("Process1");
              m_vProcess.add("Process2");
         public void WriteToXML(Vector vProcess)
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = facory.newDocumentBuilder();
              Document builder = builder.parse("Project.xml");
              TransformerFactory tfac = TransformerFactory.newInstance();
              FileWriter fileWtr = new FileWriter("output.xml");
              StreamResult strResult = new StreamResult(fileWtr);
              Transformer trans = tfac.newTransformer();
              trans.transform(new DOMSource(document.getDocumentElement()),strResult);
              Node rootNode = document.getDocumentElement();
              NodeList list = document.getElementsByTagName("Project");
    // Loop through the list.
              for (int i=0; i < list.getLength(); i++) {
              thisProjectNode = list.item(i);
              Node thisName1Node = thisProjectNode.getFirstChild();
              if (thisName1Node == null) continue;
              if (thisName1Node.getFirstChild() == null) continue;
              if (! thisName1Node.getFirstChild() instanceof
    org.w3c.dom.Text) continue;
              String data = thisName1Node.getFirstChild().getNodeValue();
              if (! data.equals("Process1")) continue;
              Node newCoffeeNode = document.createElement("Project");
              Node newName1Node = document.createElement("Process");
              Text tnNode = document.createTextNode("Process1");
              newName1Node.appendChild(tnNode);
              Node newName2Node = document.createElement("Process");
              Text tpNode = document.createTextNode("Process2");
              newName2Node.appendChild(tpNode);
              newProjectNode.appendChild(newName1Node);
              newProjectNode.appendChild(newName2Node);
              rootNode.insertBefore(newProjectNode, thisProjectNode);
              break;

  • How to get the output of Standard HR forms in PE51

    Hi Experts,
    How to get the output of standard HR forms available in PE51 Transaction for coutry grouping 99.
    Please advice.
    Regards,
    IFF

    Hi
    Use the t code for country grouping 99....PC00_M99_CEDT - Remuneration Statement. to get the variant in tcode PC00_M99_CALC_SIMU - Simulation.
    Like this test for all the standard forms, what all are the available in PE51 for country grouping 99

  • I have purchased itunes match but the cloud will not load on my ipad 4.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    i have purchased itunes match but the cloud will not load on my ipad 4.it works on my iphone 5 & it originally worked on my ipad.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    On the MBP, in iTunes, switch to Song view and enable the iCloud Status column by pulling down View > View options and selecting the option for "iCloud Status." Close the small window. Look for any tracks that have a status of "waiting." If you see several of them disable iTunes Match while holding down the Option key. Quit iTunes, wait a few seconds, then open it again and turn iTM back on. Let it compelete the scan. Wait until all tracks that are "waiting" have a status of either "matched" or "uploaded."
    On the iPad, turn off iTunes Match then launch the Music app and let the contents clear out. Power cycle the iPad for good measure, then re-enable the service once all the tracks in iTunes have been processed.

  • How to get this look in photoshop?

    How to get this look in Photoshop or by any other online application?

    if its just black and white then can i suggest one of many tutorials on youtube
    http://www.youtube.com/watch?v=9KGBIeGFvsY
    or if you wanted a more rugged look
    http://www.youtube.com/watch?v=LpHdlQRaflg

  • Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Hi connally25,
    Below is a link to a video tutorial on how to add a Facebook Log button, please check if you have followed the same steps to add the video.
    http://tv.adobe.com/watch/learn-adobe-muse-cc/adding-a-facebook-like-button/
    If you have followed the steps correctly and the button still does not work; here is a link to a forum thread which might help solving the issue:
    Facebook Follow Widget not working
    Regards
    Sonam

  • I have a 4s iPhone which I loaded the new Os on last night. Now I can not connect to iTunes. A message comes up saying i need 10.6.3 or later but I am running 10.6.1 as I have an older Mac. Anyone have ideas how to get this to work?

    I have a 4s iPhone which I loaded the new Os on last night. Now I can not connect to iTunes. A message comes up saying i need 10.6.3 or later but I am running 10.6.1 as I have an older Mac. Anyone have ideas how to get this to work?

    Its not telling you to update your iPad, its telling you you need to download a recent version itunes on your computer.
    Go here to download the newest version of iTunes.
    http://www.apple.com/itunes/?cid=OAS-US-DOMAINS-itunes.com

  • How to get the output of the report in pdf format

    how to get the output of the report in pdf format?
    Thanks in advance,
    madan.

    Refer these links
    http://www.sap-img.com/bc037.htm
    http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
    CONVERT_ABAPSPOOLJOB_2_PDF FM convert abap spool output to PDF

  • HT4929 I have (or had?) 2 alias  I followed the instructions to go from MobileMe to iCloud. But the alias stayed on MobileMe server (?) How to get this to iCloud?

    I have (or had?) 2 alias My main account is on iCloud. I followed the instructions to go from MobileMe to iCloud. But the alias stayed on MobileMe server (?) How to get this to iCloud? Not possible to put them into icloud as alias. How to keep  it working?HELP HELP because people sending me things to this email and since today no excess any more to the mobile me server? And how to move this?????
    <Emails Edited by Host>

    Firstly, I note that your profile states that you are using OS X 10.5.8, in order to use iCloud on your computer you need OS X 10.7.2 or better.
    Secondly, I have asked for your email address to be edited out. Post your address in an open thread is a sure way to be bombarded by unwanted email, remember it will be here long after you have resolved your problem, for automated detection software to find.
    If you want people to contact you, enable others to see your email address in your profile.
    Finally, are you sure that these additional addresses are aliases and not sub accounts on a family pack, aliases from MobileMe should transfer to an iCloud when you migrate.

  • When launching Illustrator on Mac OSX 10.9 I get an erro that the program is no longer supported on PowerPC. I tried moving the plug-ins to a different folder as the Adobe site suggested but no luck. Any ideas how to get this launched again? Same issue fo

    When launching Illustrator on Mac OSX 10.9 I get an error that the program is no longer supported on PowerPC. I tried moving the plug-ins to a different folder as the Adobe site suggested but no luck. Any ideas how to get this launched again? Same issue for Photoshop and InDesign

    You will need to uninstall, run the Cleaner tool and reinstall you adobe applications. Adobe apps don't take kindly to inplace updates of the OS on Macs.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6

  • HT201272 hi i bouth lion for my mac but i had to restrat my mac and it was all lost do you know how i get this back

    hi i bouth lion for my mac but i had to restrat my mac and it was all lost do you know how i get this back

    Hi..
    Better to post our topic in the Lion forum here.
    This is the iTunes Store forum.

Maybe you are looking for