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

poj 1355 Selecting the Optima...

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

poj 1355 Selecting the Optima...

#include <cstring>#include <cmath>#include <stdio.h>#include <algorithm>#include <iostream>using namespace std;int a[15] = {15,12,9,7,6,5,4,3,2,1};struct da{       char name[100],gongju[100];       int g[100],biao,score,vote;}***[100];bool ck[100],sb[100],dasb[100];int Min(int x,int y){    return x>y?y:x;}bool cmp(da xx, da yy){     if (xx.score > yy.score) return true;     if (xx.score < yy.score) return false;     if (xx.vote > yy.vote) return true;     if (xx.vote < yy.vote) return false;     if (xx.biao < yy.biao) return true;     else return false;}int main(){     int i,j,m,n,k,nn;    char ch[100];    k = 0;    while (scanf("%d",&n) != EOF)    {          if (n < 0) break;          scanf("%d",&m);          memset(***,0,sizeof(***));          memset(sb,0,sizeof(sb));          memset(dasb,0,sizeof(dasb));          for (i=1;i<=n;i++)          {   scanf("%s %s %s",ch,***[i].name,***[i].gongju);   ***[i].biao = (ch[0] - '0')*10 + ch[1]-'0';   dasb[***[i].biao] = true;          }          dasb[0] = true;          for (i=1;i<=m;i++)          {   scanf("%s",ch);   nn = strlen(ch);   memset(ck,0,sizeof(ck));   for (j=0;j<nn;j+=2)   {       k = (ch[j]-'0') * 10 + (ch[j+1] - '0');       if ((ck[k] && k > 0) || !dasb[k]) break;       else ck[k] = true;   }   if (j >= nn)   {         for (j=0;j<nn;j+=2)         {  k = (ch[j]-'0') * 10 + (ch[j+1] - '0');  for (int x=1;x<=n;x++)    if (***[x].biao == k)     {       ***[x].score += a[j/2];       ***[x].vote++;       ***[x].g[j/2 + 1]++;    }         }   }          }         sort(***+1,***+n+1,cmp);         for (i=1;i<=Min(10,n);i++)         {  printf("%-4d%02d  %-14s %-37s%6d%6d",i,***[i].biao,***[i].name,***[i].gongju,***[i].score,***[i].vote);  for (j=1;j<=10;j++)  printf("%6d",***[i].g[j]);  printf("n");         }    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380092.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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