超级难题??????????????????????????????????????????????>>>>>

来源:百度知道 编辑:UC知道 时间:2024/09/24 00:35:54
用VB编个程序,算这道题
把时钟某一刻的时针和分针调换位置,仍显示的是正确的时间,请为这个时刻是几点,把所有答案都算出来

就是时针和分针重合问题。以下时间就是的。

0:0:0 (就是12:0:0)
1:5:25
2:10:50
3:16:20
4:21:45
5:27:15
6:32:40
7:38:10
8:43:35
9:49:5
10:54:30
11:59:55

以下是C#代码,对于VB代码,你改一下格式就可以了,就只有一点点区别而已。

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int h, m, s;
double hd, md, sd;

for(h=0;h<=12;h++)
for(m=0;m<=59;m++)
for (s = 0; s <= 59; s++)
{
sd = 6 * s;
md = 6 * m + 0.1 * s;
hd = 30 * h + 0.5*m+s/120;
if (md == hd)
System.Console.WriteLine("{0}:{1}:{2}",h,m,s);