Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public static void main(String[] args) {
  2. int n = 10;
  3. Integer[] arr = {102, 140, 172,
  4. 140, 293, 69,
  5. 36, 144, 82,
  6. 44, 205, 41,
  7. 30, 10 ,193,
  8. 348, 79, 176,
  9. 396, 145, 43,
  10. 193, 132, 2,
  11. 226, 170, 43,
  12. 127, 136, 165};
  13. int s = 0;
  14. int ost;
  15.  
  16. for (int i = 0; i<n; i++){
  17. int ch = arr[i*3]*arr[i*3+1]+arr[i*3+2]; // число, сумму цифр которого надо посчитать.
  18. for (int a = 0; a<Integer.toString(ch).length(); a++){
  19. ost = ch%10;
  20. ch /= 10;
  21. s += ost;
  22. }
  23. System.out.print(s+" ");
  24. s = 0;
  25.  
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement