zoukankan      html  css  js  c++  java
  • HDU 2076 夹角有多大(题目已修改,注意读题)

    Problem Description
    时间过的好快,一个学期就这么的过去了,xhd在傻傻的看着表,出于对数据的渴望,突然他想知道这个表的时针和分针的夹角是多少。现在xhd知道的只有时间,请你帮他算出这个夹角。

    注:夹角的范围[0,180],时针和分针的转动是连续而不是离散的。
     

    Input
    输入数据的第一行是一个数据T,表示有T组数据。
    每组数据有三个整数h(0 <= h < 24),m(0 <= m < 60),s(0 <= s < 60)分别表示时、分、秒。
     

    Output
    对于每组输入数据,输出夹角的大小的整数部分。
     

    Sample Input
    2
    8 3 17
    5 13 30
     

    Sample Output
    138
    75

    import java.io.BufferedInputStream;
    import java.util.*;
    public class Main {
    	public static void main(String[] args) {
    		Scanner sc=new Scanner(new BufferedInputStream(System.in));
    		int k;
    		int h,m,s;
    		k=sc.nextInt();
    		for(int i=0;i<k;i++)
    		{
    			h=sc.nextInt();
    			m=sc.nextInt();
    			s=sc.nextInt();
    			jiSuan(h,m,s);
    		}
    	}
    	public static void jiSuan(int h,int m,int s){
    		double abs;
    		if(h>12)
    			h=h-12;
    		abs=Math.abs((h*30+m*0.5+1.0*30/3600*s)-(m*6+1.0*6/60*s));
    		if(abs>180)
    			System.out.println((int)(360-abs));
    		else 
    			System.out.println((int)abs);
    	}
    }
    


     

  • 相关阅读:
    php遍历目录下的所有文件夹
    PHP 遍历文件
    PHP中public protected private的区别
    mysql数据库优化的方法
    Thinkphp 验证器
    PHP 接口
    php获取表单的值
    PHP 数组
    php 递归
    [go系列] 函数
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3206534.html
Copyright © 2011-2022 走看看