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 Sample | Output Sample |
3 99 | 1 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; } |
Post a Comment
0Comments