黄金点
参考网址http://www.cnblogs.com/zw2013040101034/p/5370302.html
githup网址 https://github.com/chenzhuo131/golden-point/upload/master#include <iostream>
#include<math.h>
using namespace std;
void main()
{
int i, j, num, N, M, S[100], S2[100], S3[100] = { 0};
double S1[100], ave,sum,G;
double max, min;
cout << "==============欢迎进入黄金点游戏!=============" << endl;
cout << "============== HELP ==============" << endl;
cout << "=========N个玩家(N通常大于10)进行游戏=========" << endl;
cout << "==每人写一个0~100之间的有理数 (不包括0或100)==" << endl;
cout << "===========G=N位玩家平均值*0.618==============" << endl;
cout << "======最高分(N): 提交数字最接近G值的玩家======" << endl;
cout << "=====最低分(-2):提交数字距离G值最远的玩家=====" << endl;
cout << "===========其他分(0): 其他所有玩家============" << endl;
cout << "Please input the number of your game!" << endl;
cin >> N;
cout << "The number of the person:" << endl;
cin >> M;
for (i = 1; i <= N; i++)
{
sum = 0;
G = 0;
cout << "Input the number between 1 to 100." << endl;
for (j = 1; j <= M; j++)
{
cout <<" Player " << j << " input your choose!" << endl;
cin >> num;
S[j] = num;
sum = sum + S[j];
}
ave = sum / num;
G = ave*0.618;
cout << "黄金点是G=" << G << endl;
for (j = 1; j <= M; j++)
{
S1[j] = abs(S[j] - G);
}
max = min = S1[1];
for (j = 1; j <= M; j++)
{
if (S1[j] >= max)
max = S1[j];
else if (S1[j] < min)
min = S1[j];
}
for (j = 1; j <= M; j++)
{
if (S1[j] == max)
S2[j] = -2;
else if (S1[j] == min)
S2[j] = M;
else S2[j] = 0;
}
for (j = 1; j <= M; j++)
{
cout << "本轮分数" << "S2[" << j << "]=" << S2[j] << endl;
S3[j] = S3[j] + S2[j];
cout << "总分数 " << "S3[" << j << "]=" << S3[j] << endl;
}
}
system("pause");
}
刚刚接到这个分组,说实话我还是很慌的,因为我俩都不是那种大神,都只是会点c/c++的程序,像其他组的高大上的java什么的,我们并没有接触过,所以在我们结对编程中出现了很多很多的问题和分歧。但是经过磨合,我们还是克服了困难,成功的把程序写完。在这个过程中,让我认识到自己知识的欠缺,让我明白了结对编程两人合作的重要性。在这次结对作业中,我们也没有特别的进行分工,从刚开始的需求分析,算法设计,到最后的程序测试,我们都是在一起完成的,特别是编码过程中,一个人负责编程,一个人负责监督程序规范。
总之,这次结对编程,给我带来了新的体验。
浙公网安备 33010602011771号