First day ~, Firstday
It's been a long time without practicing ~ Almost everything about the C programming language.
Learn today: 1/read the problem carefully.
2/no blank between two input (scanf ("% d", & a, & B );
Prac: 2001 (http://acm.hdu.edu.cn/showproblem.php? Pid = 2001)
Calculate the distance between two points
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission (s): 95055 Accepted Submission (s): 36510
Problem Description: enter two coordinates (X1, Y1), (X2, Y2), and calculate and output the distance between two points. There are multiple groups of Input data. Each group occupies one row and consists of four real numbers, representing x1, y1, x2, and y2 respectively. Data is separated by spaces. Output outputs a row of input data for each group. The result is retained with two decimal places. Sample Input0 0 0 1 0 1 1 0 Sample Output1.00 1.41 Authorlcy Source C language programming exercises (1) RecommendJGShining | We have carefully selected several similar problems for you: 2003 2002 2004 2000 2005 first try: output limit exceeded
#include<stdio.h>#include<math.h>int main(){ int x1, y1, x2, y2; double result; while(scanf("%d %d %d %d", &x1, &y1, &x2, &y2)!=EOF){ result = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1)); printf("%.2f\n", result); } return 0;}
Why? : The input format of the question clearly indicates that the input of each group of test cases is 4 real numbers rather than 4 integers. Scanf ("% d", & n, it does not skip the characters in the failed part. Therefore, when the first decimal point is reached, the main program repeatedly enters the result of the test example that is correctly read in the last time, resulting in an over-limit input.
Second try: accepted
#include<stdio.h>#include<math.h>int main(){ double x1, y1, x2, y2, result; while(scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2)!=EOF){ result = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1)); printf("%.2lf\n", result); } return 0;}
What is the difference between the first day and at the first day?
What did you do on the first day ~~~ That is, at the end of the first day ~~~ The first day is a bit awkward --
English Writing: My First Day in the University
My first day at university
It was at 10th September that I come to my university. the first impression of this campus was the beautiful scenery. green trees and colorful flowers cocould be seen everywhere. besides, modern teaching buildings stand in the center of our campus. surrounding those well-designed buildings lie several limpid lakes. opposite the lakes, our dormitories are orderly arranged. in the morning, I looked around our teaching buildings. each classroom is wide, bright and equipped with advanced facilities.
The volunteers at the exceptionist were all passionate and considerate. the services they provided for me were of high quality. A senior student introduced a lot of rules and living structures to me. I took part in the "Communication Meeting Between Freshmen And Senior Students ". I had a good time there and met lots of new friends. after finishing the procedure of my enrollment, I went straight to my dormitory. although my room is not spacious, its comfortable and made me feel at home. my luggage was so heavy. I was nearly exhausted for carrying the big suitcase, but that didn't quench my excitement because the imagination of mycolorful college life was always with me. in the afternoon, I had a comprehensive visit of my university following the introduction regiment. the strong learning atmosphere in the library really impressed me. seeing those senior students immersed in study, I set a lofty ideals and high aspirations that in the university I must stu ...... remaining full text>