Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int calcularAlgarismo (int x){
  5.     int num = x;
  6.     int cont = 0;
  7.  
  8.     while (num/10 != 0){
  9.         num = num/10;
  10.         cont++;
  11.     }
  12.     return cont+1;
  13. }
  14.  
  15. int criaNumero (int alg, int rep){
  16.     int num = alg-1;
  17.     int sum =0;
  18.        
  19.     while(num>=0){         
  20.         sum += rep * pow(10, num); 
  21.         num--;
  22.     }
  23.  
  24. return sum;
  25. }
  26.  
  27. void main()
  28. {
  29.     int num;
  30.     printf("Digite um numero: \n");
  31.     scanf("%d", &num);
  32.     int mial = num / 8;
  33.  
  34.     while(mial>0){     
  35.         int alg = calcularAlgarismo(mial); 
  36.         int oi = criaNumero(alg, 1);
  37.  
  38.         printf("%d + ", criaNumero(alg, 8));
  39.         mial -= oi;
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement