The golden point game of pairing programming

Source: Internet
Author: User
Tags rounds

Project requirements:

The Golden Dot game is a digital mini-game whose game rules are:

n students (n usually greater than ten), each writing a rational number between 0~100 ( excluding 0 or three ), to the referee, the referee calculates the average of all the numbers, and then times the 0.618(so-called golden partition constant) , the G value is obtained. The number of the submitted nearest to G(absolute value) of the students get n points, the farthest from the G students get-2 points, the other students get 0 points. after a few days of playing, we found some interesting phenomena, such as the golden dots moving down gradually.

Now please according to the rules of the game, make up a can play with a number of small game program, the requirements are as follows:

1, this job belongs to the pair programming project, must be completed by two people, and will be sent to the blog, respectively, the operation of the source code submitted to the codeing system;

2, if possible to use the C/s or b/n as much as possible, that is, using the server to receive and process all the players submitted by the number, and the results back to the players, players can be submitted by the client number;

3, if the use of single-machine approach, it is necessary to provide users with convenient input interface;

4, the game can run at least 10 rounds at a time, and can keep the results of the rounds.

Pair member: Zhang Yi Xin Li Weiliang

Li Weiliang's coding address: https://coding.net/u/lwl123456

Li Weiliang's Blog http://www.cnblogs.com/lwl123/

My coding Address: https://coding.net/u/zhangyixin

Requirements Analysis:

This project requires that data be obtained from n users, the difference is obtained by the G-point operation, and the difference between the maximum and the minimum is given, and the game is ended and the result is output after the preset number of rounds. The idea is clear and broadly divided into the following steps:

1. Get Data from N users

2. Get the G value, the G value is the key data for the operation of this program, the algorithm for all users to provide the average number and 0.618 of the flight.

3. Obtain the nearest value of the G point and the farthest value in the user data, that is, to obtain the winner data to save the subscript and the loser data to save the subscript, first call the previous get G-point method to get the value of G, and then subtract all the data from it to get the difference array, and finally the difference in the array of each value Keep the bottom of the gap between the largest and the smallest of the subscript.

4. Data duplication, winning results and losers, we found that if the winner more than one, the loser is more than one, two positions have more than one person occupy, then the above code can not meet the requirements, so to do data duplication, get the maximum and minimum, back to the original distance data comparison, The data subscript for the maximum and minimum values is obtained.

5. Sort, the game finished running, the user's scores are different, so you need to sort out the output to make the results.

Pairing programming Experience:

This knot pair programming feeling a lot. From a procedural point of view, for me, I'm not very good at programming, not even like programming. But this pair of pairs of programming to some extent gave me confidence. There are no problems we will help each other, but there are still many places that have not been solved. such as the functional aspects of the program. At first we designed this program starting point, is to let everyone's score can be recorded, and to complete the cumulative operation, but after we actually run, there are many problems can not be resolved within the specified time. So because of the time limit, we had to Shanfanjiujian, the program to the score does not accumulate, but this change, the function of the program is not complete, but I believe that, continue to compile, we will solve the problem.

There are a few problems that are encountered with character formatting. At the beginning of the run, many of the program's for loops failed to run. No matter how you change it, the printf in the For statement can't be done, which delays us for a long time. But in the end we solved the problem because the format did not match and could not be compared. For example, if (Amin==fabs (a[i]-g)) This sentence, I set the Amin is the int type, and fabs (A[I]-G) I set the double type, which causes the two sides of the type is inconsistent, cannot compare, also causes this if he never holds, therefore inside does not run. It was a long discussion before we solved it and it took a lot of time. There are a lot of such questions, and they are not listed.

Although these problems have delayed us for a long time, but we have made great strides in programming, is called a fall into your wit. Even if the program is still incomplete, imperfect, but we paid hard sweat, and experienced the joy of programming, increased the confidence of programming. So in the next team programming, I have enough confidence to face, but also thanks to the pairing programming.

The golden point game of pairing programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.