回 帖 发 新 帖 刷新版面

主题:浙江大学ACM题目,请大家帮忙

以下是我的代码~用了STL,我认为是对的,但浙大提交上去错的
希望大家做一下是简单的题目~~~大家把自己的代码贴上来,好吗
#include"iostream"
#include"string"
#include"vector"
using namespace std;

int main()
{
    const char *q;
    vector<char> mao;
    vector<int>yu;
    vector<char>::iterator p;

    vector<int>::iterator x;
    int n,i,max,t;
    string str;
    while(cin>>n&&n)
    {
       max=0;i=0;
       cin.get();
       cin>>str;
       q=str.c_str();
       for(;*q!='\0';q++)
       {
           t=0;
            for(p=mao.begin();p!=mao.end();p++)
            {    
                if(*q==*p)
                {
                mao.erase(p);
                i--;
                t=1;
                break;
                }
            }
            if(t==0)
                {
                mao.push_back(*q);
                i++;
                }
            if(i-n>0&&i-n>max)
                max=i-n;
      }
     if(max==0)
        yu.push_back(-1);
     else if(max>0)
        yu.push_back(max);

    }
    for(x=yu.begin();x!=yu.end();x++)
    {
        if(*x==-1)
          cout<<"All customers tanned successfully."<<endl;
        else if(*x>0)
         cout<<*x<<" customer(s) walked away."<<endl;
    }
return 0;
}


回复列表 (共2个回复)

沙发

发帖的时候要把问的内容说清楚,你要大家帖代码,帖什么代码呢?你的程序是做什么的呢?浙江大学ACM题目那么多到底是哪一道呢?

板凳

1405

我来回复

您尚未登录,请登录后再回复。点此登录或注册