1145 Logical Sequence 2

SemiColon
By -
0
URI Online Judge | 1145

Logical Sequence 2

Write an program that reads two numbers X and Y (X < Y). After this, show a sequence of 1 to y, passing to the next line to each X numbers.

Input

The input contains two integer numbers X (1 < X < 20) and Y (X < Y < 100000).

Output

Each sequence must be printed in one line, with a blank space between each number, like the following example.
Input SampleOutput Sample
3 991 2 3
4 5 6
7 8 9
10 11 12
...
97 98 99


 Solution:
#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;
}


Tags:

Post a Comment

0Comments

Post a Comment (0)