Site Name

Copyright © 2019 All rights reserved | This template is made with ♥ by Gulshan

Java Programs that shows sums of digits of all possible hour minutes combinations and their occurrences24

import java.io.*; class Main { public static void main(String[] args) throws IOException { int h_digit_1 = 0; int h_digit_0 = 0; int m_digit_1 = 0; int m_digit_0 = 0; int sums[] = new int[24]; for( int sum: sums ) sum=0; int currentSum = 0; for( int h = 0 ; h < 12 ; h++ ) { if( h < 10 ) { h_digit_1 = 0; h_digit_0 = h; } else { h_digit_1 = 1; h_digit_0 = h%10; } for( int m = 0 ; m < 60 ; m++ ) { if( m < 10 ) { m_digit_1 = 0; m_digit_0 = m; } else { m_digit_1 = m/10; m_digit_0 = m - m_digit_1*10; } currentSum = h_digit_1+h_digit_0+m_digit_1+m_digit_0; sums[currentSum]++; } } for( int i = 0 ; i

published by gulshan on 2019-12-09 05:56:32

0 likes 0 dislikes

www.000webhost.com