Advertisement
lammac

Kiểm tra số Strong

Apr 3rd, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3.     int n, q, tmp, fact = 1, result = 0;
  4.     scanf("%d", &n);
  5.     q = n;
  6.     while (q != 0){
  7.         tmp = q%10;
  8.         for( int i = 1; i <= tmp; i++){
  9.             fact = fact*i;
  10.         }
  11.         result = result + fact;
  12.         fact = 1;
  13.         q = q/10;
  14.     }
  15.     if(result == n){
  16.         printf("1");
  17.     }
  18.     else{
  19.         printf("0");
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement