Advertisement
FoxTuGa

IntDiv

May 8th, 2011
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "Validations.h"
  3. #define TRUE 1
  4.  
  5. int _DivInt(int Number);
  6.  
  7. int main()
  8. {
  9.     int D, A, B, algarismo, c, count = 0;
  10.     printf("\nD: ");
  11.     scanf("%d", &D);
  12.     printf("\nA,B: ");
  13.     scanf("%d,%d", &A, &B);
  14.    
  15.     if( !_ValSupInf(D, 1, 1000) || !_ValSupInf(B-A, 1, 1000) )
  16.     {
  17.         printf("\n\nLimites Nao Respeitados!\n\n\n");
  18.         return 0;
  19.     }
  20.    
  21.     for(algarismo=A;algarismo<=B;algarismo++)
  22.     {
  23.         c = _DivInt(algarismo);
  24.         if( c == D )
  25.             count++;
  26.     }
  27.     printf("\n%d\n\n", count);
  28.  
  29.     return 0;
  30. }
  31.  
  32. int _DivInt(int Number)
  33. {
  34.     int resto, count, algarismo;
  35.     count=algarismo=0;
  36.     while(algarismo <= Number)
  37.     {
  38.         algarismo++;
  39.         resto = Number % algarismo;
  40.         if( resto == 0 )
  41.             count++;
  42.     }
  43.     return count;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement