Saturday, August 25, 2018

FLOYDS TRIANGLE

  • Problem Description

    Ram needs to arrange the numbers in order.It should be in triangle shape. Help him to arrange the numbers after giving the number of rows.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int i,j,n,count=1;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
        for(j=0;j<=i;j++)
        {
          printf("%d ",count);
          count++;
        }
        printf("\n");
        
      }

    return 0;
    }
  • Test Case 1

    Input (stdin)
    4
    
    
    Expected Output
    1 
    
    2 3 
    
    4 5 6 
    
    7 8 9 10 
  • Test Case 2

    Input (stdin)
    2
    
    
    Expected Output
    1 
    
    2 3 

No comments:

Post a Comment