HOME Forums Forum Nested loop

This topic contains 5 replies, has 1 voice, and was last updated by  nun daro 1 year, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #795 Reply

    Voeurn Sothavith
    Nested Loop
    
    N = 10
    
    1
    1 1
    1 0 1
    1 0 0 1
    1 0 0 0 1
    1 0 0 0 0 1
    1 0 0 0 0 0 1
    1 0 0 0 0 0 0 1
    1 0 0 0 0 0 0 0 1
    1 1 1 1 1 1 1 1 1 1
    
    #874 Reply

    RaksmeyChea

    Who can help him for this problem, please…

    #876 Reply

    Pon Koemse
    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    	int n;
    	cout<<"Enter N "; cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=i;j++)
    		{
    			if(j==1||j==i||i==n)
    				cout<<"1 ";
    			else
    				cout<<"0 ";
    		}
    		cout<<endl;
    	}
    	getch();
    }
    
    
    
    		
    	
    #879 Reply

    RaksmeyChea

    Great, much thanks for ur help Koemse.

    #881 Reply

    Tang Seakmeng

    Excuse me, Teacher!
    I don’t understand this sentence

    if(j==1||j==i||i==n)

    Thanks!

    #890 Reply

    nun daro

    Excuse me I have write as kimse show but It error in(if(j==1||j==i||i==n))

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Nested loop
Your information: