Sunday, 27 March 2016

Solution of URI 1145 :: Logical Sequence 2


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int X,Y,z,a,b=0;
    scanf("%d%d", &X,&Y);
    for(a=1; a<=Y; a++)
    {
        b++;
        if(b==X) printf("%d",a);
        else printf("%d ", a);
        if(b==X)
        {
            b=0;
            printf("\n");
        }
    }
    return 0;
}

18 comments:

  1. if(b==X)
    printf("%d",a);
    else printf("%d ", a);
    if(b==X)
    {
    b=0;
    printf("\n");
    }
    Can I use same conditions ? Like u use if(a==x) twice.

    ReplyDelete
  2. I has been tried to solve this problem . But always seems the presentation error . #include
    int main()
    {
    int i,n,a,b=0;
    scanf("%d %d",&a,&n);

    for(i=1; i<=n; i++)
    {
    printf("%d ", i);
    b++;
    if(b==a)
    {
    printf("\n");
    b=0;
    }
    }

    return 0;
    }
    l


    whats the problem

    ReplyDelete
  3. #include
    int main()
    {
    int X,Y,j,i;
    scanf("%d%d", &X,&Y);
    if(Y>X)
    for(i=1;i<=Y;i=i+X)
    {
    for(j=i;j<X+i;j++)
    {
    printf("%d ", j);
    }
    printf("\n");
    }
    return 0;
    }




    PRESENTATION ERROR WHY? please,,,,

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. #include
    int main()
    {
    int x,y,i,j=0;
    scanf("%d %d",&x,&y);

    for(i=1;i<=y;i++)
    {
    printf("%d",i);
    j++;
    if(j<x)
    printf(" ");
    else
    {
    printf("\n");
    j=0;
    }
    }
    return 0;
    }

    ReplyDelete
  6. #include
    using namespace std;
    main(){
    int x,y,i,j,a;
    cin >> x;
    cin >> y;

    if((x>1 && x<20) && (y>x) && y<100000){
    for(i=1;i<=y;i++){
    a=i;
    for(j=1;j<=x;j++){
    if(a==y){
    cout << a << " ";
    a++;
    break;
    }
    else{
    cout << a << " " ;
    a++;
    }
    }
    cout << endl;
    i+=x-1;
    }
    }
    }

    why presentation error

    ReplyDelete
  7. #include
    void main(void){
    int x, y, cont;
    scanf("%i", &x);
    do{
    scanf("%i", &y);
    }while(y <= x);
    for (cont = 1;cont <= y; cont++){
    if (cont % x == 0 || cont == y){
    printf("%i\n", cont);
    }
    else{
    printf("%i ", cont);
    }
    }
    }

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. #include
    int main ()
    {
    int n,a,h;

    scanf ("%d%d",&a,&h);
    for (n=1;n<=h;n++)
    {
    if (n%a==0)
    {
    printf ("%d \n",n);
    }
    else
    {
    printf ("%d ",n);}

    }
    return 0;
    }

    ReplyDelete
  10. What is the problem in this code can anyone help me

    #include

    int main()
    {

    int i, x, y, j, c = 1;

    scanf("%d %d", &x, &y);

    for (i = 1; i <= y; i++)
    {

    for (j = 1; j <= x; j++)
    {

    if (c == y + 1)
    {
    break;
    }
    if (c == x)
    {
    printf("%d", c++);
    }
    else
    {
    printf("%d ", c++);
    }
    }


    printf("\n");

    if (c == y + 1)
    {
    break;
    }
    }
    }

    ReplyDelete
  11. # include

    int main ()
    {
    int x,y;
    scanf("%d%d", &x,&y);
    int i;
    for (i=1; i<=y; i++)
    {
    if((i%x)==0)
    {
    printf("%d\n", i);
    }
    else
    {
    printf("%d ",i);
    }
    }

    return 0;
    }

    ReplyDelete
  12. #include
    #include

    int main()
    {
    int i, s, j, k, temp=0;
    scanf("%d %d", &s, &j);
    for(i=1; i<=j; i++)
    {
    printf("%d ",i);
    temp+=1;
    if(temp%s==0)
    {
    printf("\n");
    }
    }

    return 0;
    }

    ReplyDelete
  13. why I'm getting presentation error?

    ReplyDelete
  14. #include

    int main()
    {
    int x, y, i, j, n, m;
    scanf("%d%d",&x,&y);
    for(i=1;i<=y;i++)
    {
    if(i%x==0)
    {
    printf("%d\n",i);

    }
    else
    {
    printf("%d ",i);
    }
    }

    return 0;
    }

    ReplyDelete
  15. #include
    using namespace std;
    int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 1; i <= y; i++) {
    cout << i << " ";
    if (i % x == 0)
    cout << endl;

    }
    }
    i got presention error

    ReplyDelete

Note: only a member of this blog may post a comment.