After nearly two weeks of programming for the project, many of them have also discovered many of their own problems. In the process of pair programming, such as discussing the Division of labor, at first do not know how to start, and then after a slow discussion with a more reasonable division of labor. My partner and I have different personalities and ways of working, and in the process of doing the project there will be many different ideas and ideas, programming habits are not the same. He likes to start with the whole, first think good program every link, after the idea of the whole, only began programming. As far as I am concerned, I am accustomed to one layer at a time, the gradual programming, each link completes and then carries on the next item, although the efficiency is a bit slow, but for me, this kind of way can let me in the programming when the error. I like the way my companion has done the whole idea in advance, and I will try to write the code in this way for later programming, which is very helpful for bigger picture.
During programming, because of the number of innings and number of people, a two-dimensional array is defined, the row is labeled as the number of games, the numbers are counted, the data entered by each player is stored in a two-dimensional array, then the gold points are calculated, the game is scored for each player, and the score is placed in another array. Count each player's game score, output the final score, and deposit in the file. The programming process is smooth without encountering too much problem, and some minor errors are quickly corrected. We did not do the interface, the students useful Java to do, the interface is very good, I am also learning java. But I can only write a Hello World at the moment.
There is a tendency to reduce the number of input values in the game. We make an ideal assumption that the player's data is definitely random input, then the average value is close to the median (data from small to large) of the set of data. The golden point on the average base of 0.618, about the first half of the data of the upper and middle, that is, the entire group of data about 30% (data from the arrival of the arrangement), so you will find that the winner of the data is often relatively small, naturally in the beginning of a new round of games will be appropriate to reduce their data.
Program code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void Main ()
{
int a[20][20], grade[20], I, J, K1, K2, T, b, data, total = 0;
Double min = +, max = 0, average = 0;
FILE *FP;
Char ch;
printf ("Please Enter game board number: \ n");
scanf_s ("%d", &t);
printf ("Please enter the number of games: \ n");
scanf_s ("%d", &b);
for (j = 0; J < b; j + +)
{
GRADE[J] = 0;
}
for (i = 0; i < T; i++)
{
printf ("%d game start: \ n", i + 1);
printf ("Please enter the participant's data: \ n");/* Only the first person to enter the same data in a single Bureau score */
for (j = 0; J < b; j + +)
{
scanf_s ("%d", &data);
A[I][J] = data;
Total = total + data;
}
Average = total/b*0.618;
printf ("Golden dots:%.4f", average);/* Print golden Dots */
for (j = 0; J < b; j + +)
{
if (Fabs (A[i][j]-average) < min)
{
min = Fabs (A[i][j]-average);
K1 = j;
}/* Find the nearest person in the current station to the golden point */
if (Fabs (A[i][j]-average) > Max)
{
max = Fabs (A[i][j]-average);
K2 = j;
}/* Find the person who is farthest from the golden point at the current station * *
}
GRADE[K1] = Grade[k1] + t; /* Add points for winners */
GRADE[K2] = Grade[k2]-2; /* for negative minus points */
printf ("Output this council score: \ n");
for (j = 0; J < b; j + +)
{
printf ("%d", grade[j]);
}
printf ("\ n");
min = 100;
max = 0;
Total = 0;
}
printf ("Game over, everyone scored as follows: \ n");
if (fp = fopen ("D:\\zmh.txt", "w+") = = = NULL)
{
printf ("Cannot open file");
Exit (1);
}
for (j = 0; J < b; j + +)
{
printf ("%d", grade[j]); /* Print everyone score */
if (Grade[j] < 0)
{
GRADE[J] = ABS (Grade[j]);
ch = '-';
FPUTC (CH, FP);
}
CH = grade[j] + ' 0 ';
FPUTC (CH, FP);
ch = ";
FPUTC (CH, FP);
}
printf ("\ n");
max = 0;
for (j = 0; J < b; j + +)
{
if (Grade[j] > Max)
{
max = Grade[j]; /* Compare the highest score */
}
}
for (j = 0; J < b; j + +)
{
if (Grade[j]==max)
printf ("Highest score is%d", J + 1, grade[j]); */* The highest scoring person can be tied/*
}
Fclose (FP);
GetChar ();
GetChar ();
}
Golden Dot Game Two-man knot pair project summary