Monday 14 March 2016

Pattern 6


Write a program to print the given pattern.

Input Format:
Input consists of a single integer.

Output Format:
Refer sample output. There is a trailing space at the end of each line.

Sample Input:
5


5
4 5 
3 4 5
2 3 4 5
1 2 3 4 5


code:

  #include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=n;i>=1;i--)
  {
    for(j=i;j<=n;j++){   
      printf("%d ",j);
    
    }
    printf("\n");
  } 
  return 0;
}

2 comments:

  1. #include
    int main(){
    int n,i,j,a,k;
    scanf("%d",&n);
    for(i=n;i>=1;i--)
    {
    k=i;
    for(j=i;j<=a;j++){
    printf("%d ",k);k++;

    }
    printf("\n");a++;
    }
    return 0;
    }

    ReplyDelete
  2. #include
    int main()
    {
    int n,i,j,a,k;
    scanf("%d",&n);
    for(i=n;i>=1;i--)
    {
    k=i;
    for(j=i;j<=n;j++)
    {
    printf("%d ",k);
    k++;
    }
    printf("\n");
    a++;
    }
    return 0;
    }

    ReplyDelete