Advertisement
Guest User

Untitled

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