Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <math.h>
- int a,b;
- int Armstrong(long long n)
- {
- long long t, scs=0, cs=0;
- long long m=n;
- long long b=n;
- while(n>0)
- {
- n/=10;
- scs++;
- }
- while(m>0)
- {
- t=m%10;
- cs+=pow(t, scs);
- m/=10;
- }
- if(cs==b) return 1;
- else return 0;
- }
- int main()
- {
- long long a, b, kt = 0;
- scanf("%d %d",&a, &b);
- if(a<b)
- {
- for(int i=a; i <=b ; i++)
- {
- if(Armstrong(i))
- {
- printf("%d ", i);
- kt = 1;
- }
- }
- }
- else
- {
- for(int i=b; i <=a ; i++)
- {
- if(Armstrong(i))
- {
- printf("%d ", i);
- kt = 1;
- }
- }
- }
- if (kt == 0) printf("0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement