c語言黃金點遊戲

來源:互聯網
上載者:User

標籤:div   min   lib   基本   poi   ++   sys   ring   print   

    經過不斷的努力,此代碼還有一點瑕疵,準系統已實現。
#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];printf("歡迎來到黃金點遊戲!\n"); printf("請輸入遊戲輪數:\n"); scanf_s("%d", &M); printf("請輸入遊戲人數:\n"); scanf_s("%d", &N); memset(score,0,sizeof(int)*N);for (i = 0; i < M; i++) { printf("\n第%d輪遊戲:\n",i+1); for (j = 0; j < N; j++) { printf("請輸入一個0-100的數:\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人本輪後總分數為%d:\t",k+1,score[k]);}sum = 0; printf("黃金點是%f", G);max=0;min=0;}return 0; }int main() { point(); system("pause"); }
註:本部落格為原創,轉載請申明

  

c語言黃金點遊戲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.