首页 > 代码库 > poj1013

poj1013

  1 #include <iostream>
  2 using namespace std;
  3 
  4 
  5 int weigh[12]={0};
  6 
  7 char dol[3][12];
  8 int ba[3];
  9 char dollar(int n);
 10 int abs(int num);
 11 int main()
 12 {
 13     char c;
 14     int j=0;
 15     int k=0;
 16     int n;
 17     cin >>n;
 18     wdffhile(n!=0)
 19     {
 20         n--;
 21         for(int i=0;i<3;i++)
 22         {
 23             j=0;
 24             while(1)
 25             {
 26                 cin >>c;
 27                 if(c>=A&&c<=L)
 28                     dol[i][j++]=c;
 29                 if(c==e)
 30                 {
 31                     ba[i]=0;
 32                     cin >>c;
 33                     cin >>c;
 34                     cin >>c;
 35                     break;
 36                 }
 37                 if(c==u)
 38                 {
 39                     ba[i]=1;
 40                     cin >>c;
 41                     break;
 42                 }
 43                 if(c==d)
 44                 {
 45                     ba[i]=2;
 46                     cin >>c;
 47                     cin >>c;
 48                     cin >>c;
 49                     break;
 50                 }
 51             }
 52         }
 53         c=dollar(j);
 54         cout <<dollar;
 55     }
 56     return 0;
 57 }
 58 
 59 
 60 
 61 char dollar(int n)
 62 {
 63     char c;
 64     int temp=0;
 65     for(int i=0;i<3;i++)
 66         for(int j=0;j<n;j++)
 67             dol[i][j]-=A;
 68     for(int i=0;i<3;i++)
 69     {
 70         if(ba[i]==0)
 71         {
 72             for(int j=0;j<n;j++)
 73                 weigh[dol[i][j]]+=30;
 74         }
 75         if(ba[i]==1)
 76         {
 77             for(int j=0;j<n;j++)
 78                 weigh[dol[i][j]]+=1;
 79         }
 80         if(ba[i]==2)
 81         {
 82             for(int j=0;j<n;j++)
 83                 weigh[dol[i][j]]-=1;
 84         }
 85     }
 86     for(int i=0;i<3;i++)
 87     {
 88         for(int j=0;j<n;j++)
 89         {
 90             if(abs(weigh[dol[i][j]])>temp&&abs(weigh[dol[i][j]]<4))
 91             {
 92                 temp=abs(weigh[dol[i][j]]);
 93                 c=dol[i][j];
 94             }
 95         }
 96     }
 97     return c;
 98 }
 99 
100 
101 int abs(int num)
102 {
103     return num>0?num:-num;
104 }

 

poj1013