给定以小时为单位的时间,找出下一个小时分针和时针重合的时间(以分钟为单位)。 例如:
null
Input : 3 Output : (180/11) minutesInput :7Output : (420/11) minutes
方法: 1.取小时“h1和h2”的两个变量,然后求出角度“θ”[θ=(30*h1)],然后除以“11”,以分钟(m)为单位计算时间。我们用11除以,因为时钟的指针在12小时内与11的时间重合,在24小时内与22的时间重合: 公式: 这可以使用时间h1到h2的公式计算,即[11m/2–30(h1)] 这意味着[m=((30*h1)*2)/11]] [m=(θ*2)/11] 式中[theta=(30*h1)] 其中A和B是小时,即如果给定的小时是(2,3),那么A=2,B=3。
C++
// CPP code to find the minute at which // the minute hand and hour hand coincide #include <bits/stdc++.h> using namespace std; // function to find the minute void find_time( int h1) { // finding the angle between minute // hand and the first hour hand int theta = 30 * h1; cout << "(" << (theta * 2) << "/" << "11" << ")" << " minutes" ; } // Driver code int main() { int h1 = 3; find_time(h1); return 0; } |
JAVA
// Java code to find the minute // at which the minute hand and // hour hand coincide import java.io.*; class GFG { // function to find the minute static void find_time( int h1) { // finding the angle between // minute hand and the first // hour hand int theta = 30 * h1; System.out.println( "(" + theta * 2 + "/" + " 11 ) minutes" ); } //Driver Code public static void main (String[] args) { int h1 = 3 ; find_time(h1); } } // This code is contributed by // upendra singh bartwal |
Python3
# Python3 code to find the # minute at which the minute # hand and hour hand coincide # Function to find the minute def find_time(h1): # Finding the angle between # minute hand and the first # hour hand theta = 30 * h1 print ( "(" , end = "") print ((theta * 2 ), "/ 11) minutes" ) # Driver code h1 = 3 find_time(h1) # This code is contributed by # Smitha Dinesh Semwal |
C#
// C# code to find the minute // at which the minute hand // and hour hand coincide using System; class GFG { // function to find the minute static void find_time( int h1) { // finding the angle between minute // hand and the first hour hand int theta = 30 * h1; Console.WriteLine( "(" + theta * 2 + "/" + " 11 )minutes" ); } //Driver Code public static void Main() { int h1 = 3; find_time(h1); } } // This code is contributed by vt_m. |
PHP
<?php // PHP code to find the minute // at which the minute hand and // hour hand coincide // function to find the minute function find_time( $h1 ) { // finding the angle between // minute hand and the first // hour hand $theta = 30 * $h1 ; echo ( "(" . ( $theta * 2) . "/" . "11" . ")" . " minutes" ); } // Driver code $h1 = 3; find_time( $h1 ); // This code is contributed by Ajit. ?> |
Javascript
<script> // JavaScript code to find the minute at which // the minute hand and hour hand coincide // function to find the minute function find_time(h1) { // finding the angle between minute // hand and the first hour hand theta = 30 * h1; document.write( "(" + (theta * 2) + "/" + "11" + ")" + " minutes" ); } // Driver code h1 = 3; find_time(h1); // This code is contributed by Surbhi Tyagi. </script> |
输出:
(180/11) minutes
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END