Advertisement
noshin98

uva 12895

Jul 10th, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5.     int t,i,N,orgN,digit,n;
  6.     scanf("%d",&t);
  7.     for(i=1;i<=t;i++)
  8.     {
  9.  
  10.         scanf("%d",&N);
  11.         n=0;
  12.         orgN=N;
  13.  
  14.         while(N>0)
  15.         {
  16.             N/=10;
  17.             n++;
  18.         }
  19.         N=orgN;
  20.  
  21.         while(N>0)
  22.         {
  23.             digit=N%10;
  24.             N/=10;
  25.             orgN=orgN-pow(digit,n);
  26.  
  27.         }
  28.         if(orgN==0) printf("Armstrong\n");
  29.         else printf("Not Armstrong\n");
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement