Friday, October 26, 2018

Uri 1145 solution in C | Logical Sequence 2

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/

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

 //Happy_Coding

No comments:

Post a Comment