Write a function to give out all the time (hour:minute) that the angle between minute hand and hour hand on a clock is 90 degree.

static void Main(string[] args)

{

for (int h = 0; h < 12; h++)

{

double m = 1.0;

double angle = 1.0

if (h < 9)

{

m = 1.0*(60 * h + 180) / 11;

angle = (m – h * 5 – m / 12) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h > 9)

{

m = 1.0 * (60 * h – 540) / 11;

angle = (h * 5 + m / 12 – m) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h < 3)

{

m = 1.0 * (60 * h + 540) / 11;

angle = (m – h * 5 – m / 12) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

if (h > 3)

{

m = 1.0 * (60 * h – 180) / 11;

angle = (h * 5 + m / 12 – m) * 6;

Console.WriteLine("{0}:{1} {2}", h, (int)m, angle);

}

}

}

Advertisements
This entry was posted in 计算机与 Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s