Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- int n = 10;
- Integer[] arr = {102, 140, 172,
- 140, 293, 69,
- 36, 144, 82,
- 44, 205, 41,
- 30, 10 ,193,
- 348, 79, 176,
- 396, 145, 43,
- 193, 132, 2,
- 226, 170, 43,
- 127, 136, 165};
- int s = 0;
- int ost;
- for (int i = 0; i<n; i++){
- int ch = arr[i*3]*arr[i*3+1]+arr[i*3+2]; // число, сумму цифр которого надо посчитать.
- for (int a = 0; a<Integer.toString(ch).length(); a++){
- ost = ch%10;
- ch /= 10;
- s += ost;
- }
- System.out.print(s+" ");
- s = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement