歼灭弱题8

zoj2104
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string cc[1000],maxs,t;
    int n,i,j,max,cnt,k;
    while(cin >> n)
    {
        if(n==0) break;
        if(n==1)
        {
            cin >> t;
            cout << t << endl;
            continue;
        }
        i=0;max=0;
        while(n--)
        {
            cin >> cc[i];
            ++i;
        }
        for(j=0;j<i-1;++j)
        {
            if(cc[j]!="")
            {
                t=cc[j];
                cc[j]="";
                cnt=1;
            }
            else
                continue;
            for(k=j+1;k<i-1;++k)
            {
                if(cc[k]==t){ cc[k]=""; cnt++;}
            }
            if(max<cnt){max=cnt;maxs=t;}
        }
        cout << maxs << endl;
    }
    return 0;
}
ZOJ2514 犯了点小错,忙活了那么久
#include<iostream>
#include<string>
using namespace std;
int main()
{
 string * id,* pass;
 int n,i,cnt,* key,x,tt;
 while(cin >> n)
 {
  if(n==0) break;
  id = new string[n];
  pass = new string[n];
  key = new int[n];
  i=-1,cnt=0;
  tt=n;
  while(tt--)
  {
   i++;
   cin >> id[i] >> pass[i];
   key[i]=0;
   for(x=0;x<pass[i].size();++x)
   {
    if(pass[i][x]=='1')
    {
     key[i]=1;
     pass[i][x]='@';
    }
    else if(pass[i][x]=='0')
    {
     key[i]=1;
     pass[i][x]='%';
    }
    else if(pass[i][x]=='l')
    {
     key[i]=1;
     pass[i][x]='L';
    }
    else if(pass[i][x]=='O')
    {
     key[i]=1;
     pass[i][x]='o';
    }
   }
   if(key[i]==1) cnt++;
  }
  if(cnt!=0)
  {
   cout << cnt << endl;
   for(x=0;x<n;++x)
   {
    if(key[x]!=0)
     cout << id[x] << " " << pass[x] << endl;
   }
  }
  else
  {
   cout << "No account is modified." << endl;
  }
  delete[] id;
  delete[] pass;
  delete[] key;
 }
 return 0;
}
ZOJ2176 这个太……太……代码都不好意思贴
ZOJ2172 同上
ZOJ2191  极品弱题
ZOJ 2256 看似复杂实际却摆脱不了弱的本色
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int n;
    double value;
    while(cin >> n)
    {
        if(n==0) break;
        if(n<=4)
            cout << 10 << endl;
        else if(n<=8)
            cout << 10+(n-4)*2 << endl;
        else if(n%8==0)
        {
            cout << 18*(n/8) << endl;
        }
        else if(n%8<5)
        {
            value = 18*(n/8)+n%8*2.4;
            cout <<setiosflags(ios::fixed)<< setprecision(1) << value << endl;
        }
        else
        {
            cout << 18*(n/8)+10+2*(n%8-4) << endl;
        }
    }
    return 0;
}

ZOJ2185
#include <iostream>
using namespace std;
int main()
{
    int n;
    int sum,i;
    while(cin >> n)
    {
        sum=0;i=1;
        if(n==1){cout << "TERM 1 IS 1/1" << endl;continue;}
        while(sum+i<n)
        {
            sum+=i;
            i++;
        }
        if(i%2==0)
        {
            cout << "TERM " << n << " IS " << n-sum << "/" << i+1-(n-sum) << endl;
        }
        else
        {
            cout << "TERM " << n << " IS " << i+1-(n-sum) << "/" << n-sum << endl;
        }
    }
    return 0;
}
posted on 2006-08-10 18:32  AnewR  阅读(229)  评论(0)    收藏  举报