时钟夹角.cpp
来自「求任意时刻时钟的夹角」· C++ 代码 · 共 20 行
CPP
20 行
#include <stdio.h>
#include <math.h>
void main()
{
int h,m;
float a;
while(1)
{
scanf("%d %d",&h,&m);
if(h==0&&m==0)
break;
else
{
a=(float)m/60*360-((float)m/60*30+h*30);
m<10?printf("At %d:0%d the angle is ",h,m):printf("At %d:%d the angle is ",h,m);
a>180?printf("%.1f degrees.\n",360-a):a>0?printf("%.1f degrees.\n",a):a>-180?printf("%.1f degrees.\n",-a):printf("%.1f degrees.\n",360+a);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?