第五界学生编程大赛题目.docVIP

  • 11
  • 0
  • 约1.97千字
  • 约 8页
  • 2023-10-25 发布于浙江
  • 举报
1、求绝对值 Problem Description 求实数的绝对值。 Input 输入数据有多组,每组占一行,每行包含一个实数。 Output 对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。 Sample Input 123 -234.00 Sample Output 123.00 234.00 答案: #include math.h #include stdio.h int main(void) { double r; while (scanf(%lf, r) != EOF) printf(%.2lf\n, fabs(r)); return 0; } 2、计算两点间的距离 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。 Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。 Output 对于每组输入数据,输出一行,结果保留两位小数。 Sample Input 0 0 0 1 0 1 1 0 Sample Output 1.00 1.41 答案: #include cmath #include cstdio int main(void) { double

文档评论(0)

1亿VIP精品文档

相关文档