After a constant effort, this code has a little flaw, and the basic functionality has been implemented.
#include <stdio.h> #include <stdlib.h> #include <string.h>int point () {int i,j,k,m,n; int max = 0, min = 0; int m[100], n[100]; Double average, g,sum = 0.0;int score[100];p rintf ("Welcome to the Golden Dot game! \ n "); printf ("Please enter the number of game rounds: \ n"); scanf_s ("%d", &m); printf ("Please enter the number of games: \ n"); scanf_s ("%d", &n); memset (score,0,sizeof (int) *n); for (i = 0; i < M; i++) {printf ("\ n%d-wheel game: \ n", i+1); for (j = 0; J < N; J + +) {printf ("Please enter a 0-100 number: \ n"); scanf_s ("%d", &m[j]); sum = sum + m[j]; Average = sum/n; G = average*0.618; N[J] = m[j]-G; n[j]= (n[j]>0)? N[J]: n[j]* (-1); Max= (N[j]<n[max])? Max:j;min= (N[j]<n[min])? J:min; }//printf ("\n%d\n", Max),//printf ("%d\n", Min), score[max]-=2;score[min]+=2;for (k=0;k<n;k++) {printf ("% D people the total score after this round is%d:\t ", K+1,score[k]);} sum = 0; printf ("Golden dot is%f", G); max=0;min=0;} return 0; }int Main () {point (); System ("pause"); }
Note: This blog is original, reproduced please declare
C-language golden dot game