Code For Alls..!

get the code!!

Friday, 21 July 2017

Numbers with Unit Digit

Given two positive integers A and B and a digit U, the program must print all the integers from A to B (inclusive of A and B), which have their unit digit as U.
Input Format:
The first line contains A
The second line contains B
The third line contains U
Output Format:
The first line contains the integers from A to B having their unit digit as U in ascending order with each integer separated by a space.
Boundary Conditions:
1 <= A,B <= 99999
0 <= U <= 9
Example Input/Output 1:
Input:
20
210
3
Output:
23 33 43 53 63 73 83 93 103 113 123 133 143 153 163 173 183 193 203

C code:

#include<stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,n,i;
    scanf("%d\t%d\t%d",&a,&b,&n);
    for(i=(a/10)*10+n-10;i+10<=b;i+=10)
    printf("%d\t",i+10);
}



Python code:
a,b,n=[int(input()) for _ in range(3)]
for i in range((a//10)*10+n-10,b-9,10):
    print(i+10)