計算三個刻度的密碼鎖,要打開總共需要轉幾度
[心得]
1.順和逆時針指的都是轉盤,刻度移動的方向和他相反 (圖要看仔細)
2.所轉的刻度數還要換成degree
#include <stdio.h>
int main()
{
int start,first,second,third;
int degree;
while(scanf("%d %d %d %d",&start,&first,&second,&third))
{
if(!start &&!first &&!second &&!third) break;
degree=1080;
if(first>start) degree+=(start+40-first)*9;
else degree+=(start-first)*9;
if(first>second) degree+=(second+40-first)*9;
else degree+=(second-first)*9;
if(third>second) degree+=(second+40-third)*9;
else degree+=(second-third)*9;
printf("%d\n",degree);
}
return 0;
}
全站熱搜
留言列表