Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. int b;
  3. int sum(int a)
  4. {
  5.     b = 0;
  6.     while (a != 0)
  7.     {
  8.         b = b + a % 10;
  9.         a = a / 10;
  10.     }
  11. return b;
  12. }
  13.  
  14. int main()
  15. {
  16.     int a, c = 0;
  17.     for (a = 1; a <= 10000; ++a)
  18.     {
  19.         sum(a);
  20.         if (b == 30) printf("%d ", a);
  21.         c = c + b;
  22.     }
  23.     printf("\n\nSumma cifr vseh chisel: %d ", c);
  24.     printf("\n\n");
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement