M. From This to That
Problem linkhttps://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/M
Score: 1
CPU: 1s
Memory: 512MB
CPU: 1s
Memory: 512MB
Another very simple task. You are given two integers a and b. You can assume that a<=b. Your task is to print all integers from a to b.
Input
A pair of integers a and b (a<=1000, b<=1000, a<=b)
Output
Print all integers from a to b in a single line. Separate each integers with a single space. Make sure not to print any leading or trailing space.
Sample
Input | Output |
---|---|
1 5 | 1 2 3 4 5 |
Solution
#include<stdio.h> int main() { int a,b,i; scanf("%d%d",&a,&b); if(a<=1000 && b<=1000 && a<=b){ for(i=a;i<=b;i++){ printf("%d",i); if(i!=b) printf(" "); } printf("\n"); } return 0; }
No comments:
Post a Comment