Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Sunday 30 October 2016

M. From This to That
Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/M

Score: 1

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

InputOutput
1 51 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