此博客链接:https://www.cnblogs.com/ping2yingshi/p/12243098.html
1.两点间距离(10min)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2001
题解:
此题需要知道两点间距离公式:|
#include<stdio.h> #include<math.h> int main(void) { double x1,x2,y1,y2; double dis; double temp; while(~scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2)) { dis=0; temp=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); dis=sqrt(temp); printf("%0.2lf\n",dis); } return 0; }
2.第几天(24min)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2005
#include<stdio.h> #include<math.h> int main(void) { int year; int month; int day; int i; int month1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//平年 int month2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//润年 while(~scanf("%d/%d/%d",&year,&month,&day)) { int days=0; if((year%4==0&&year%100!=0)||year%400==0)//判断润年 for(i=0;i<month;i++) days=days+month2[i]; else for(i=0;i<month;i++) days=days+month1[i]; days=days+day; printf("%d\n",days); } return 0; }
原文:https://www.cnblogs.com/ping2yingshi/p/12243098.html