栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1224 Stats

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1224 Stats

#include <iostream>#include<stdio.h>#include<string.h>using namespace std; int main() {     int n;     int HIT[56] = { 0 };     int ERR[56] = { 0 };     int DIG[56] = { 0 };     int KILL[56] = { 0 };     int BLOCK[56] = { 0 };     int GAMES[56] = { 0 };     char key;    int GameCount = 0;     int CurrentPlayerNumber;     while(cin >> key)     {         if(key == 'C')         {  cin >> n; for(int i = 0; i < n; i++)  {     cin >> CurrentPlayerNumber;      GAMES[CurrentPlayerNumber]++;  }  GameCount++;  continue;         }        if(key == 'H')         {  cin >> CurrentPlayerNumber; HIT[CurrentPlayerNumber]++;  continue;         }         if(key == 'K')         {  cin >> CurrentPlayerNumber;  KILL[CurrentPlayerNumber]++;  continue;         }         if(key == 'E')       {  cin >> CurrentPlayerNumber; ERR[CurrentPlayerNumber]++;  continue;         }         if(key == 'B')         {  cin >> CurrentPlayerNumber;  BLOCK[CurrentPlayerNumber]++;  continue;         }         if(key == 'D')         {  cin >> CurrentPlayerNumber;  DIG[CurrentPlayerNumber]++;  continue;         }         cout << "Player  Hit Pct    KPG      BPG      DPG" << endl;         cout << "-----------------------------------------" << endl;        for(int i = 0; i <= 55; i++)  if(GAMES[i])  {      double HitPct = 0.0;      if(KILL[i] + ERR[i] + HIT[i])          HitPct = double(KILL[i] - ERR[i]) / (KILL[i] + ERR[i] + HIT[i]);      double KPG = double(KILL[i]) / GAMES[i];      double BPG = double(BLOCK[i]) / GAMES[i];      double DPG = double(DIG[i]) / GAMES[i];      printf("%02d      %+5.3f  % 7.3f  % 7.3f  % 7.3f", i, HitPct, KPG, BPG, DPG);      cout << endl;  }         int SumBLOCK = 0;         int SumKILL = 0;         int SumERR = 0;          int SumDIG = 0;         int SumHIT = 0;         for(int i = 0; i <= 55; i++)  if(GAMES[i])  {      SumBLOCK += BLOCK[i];      SumKILL += KILL[i];      SumERR += ERR[i];      SumDIG += DIG[i];      SumHIT += HIT[i]; }         double HitPct = 0.0;         if(SumKILL + SumERR + SumHIT)  HitPct = double(SumKILL - SumERR) / (SumKILL + SumERR + SumHIT);         double KPG = double(SumKILL) / GameCount;         double BPG = double(SumBLOCK) / GameCount;         double DPG = double(SumDIG) / GameCount;         printf("team    %+5.3f  % 7.3f  % 7.3f  % 7.3f", HitPct, KPG, BPG, DPG);          cout << endl << endl;          memset(HIT, 0, sizeof(HIT));         memset(ERR, 0, sizeof(ERR));         memset(DIG, 0, sizeof(DIG));         memset(KILL, 0, sizeof(KILL));         memset(BLOCK, 0, sizeof(BLOCK));         memset(GAMES, 0, sizeof(GAMES));         GameCount = 0;     }     return 0; }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/373319.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号