Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

虽然代码比较烂,可是看不出为啥错额,附代码,求各位帮忙看看!

Posted by jiayiyang123 at 2014-03-11 14:55:10 on Problem 2664
#include<iostream>
#include<vector>

using namespace std;
struct categories
{
    int num;
    int leastnum;
    vector<string> courseid;
};
int main()
{
    int k,i;
    cin>>k;
    vector<string> courseselected;
    while(k!=0)
    {
        int m;

        cin>>m;
        categories *cate=new categories[m];
        for(i=0;i<k;i++)
        {
            string a;
            cin>>a;
            courseselected.push_back(a);
        }
       // int flagno=0;
        int flag=0;
        for(i=0;i<m;i++)
        {


            cin>>cate[i].num>>cate[i].leastnum;
            for(int j=0;j<cate[i].num;j++)
            {
                string id;
                cin>>id;
                cate[i].courseid.push_back(id);
            }
            int count=0;
            for(int j=0;j<courseselected.size();j++)
            {
                for(int k=0;k<cate[i].courseid.size();k++)
                {
                    if(courseselected[j]==cate[i].courseid[k])
                    {
                        count++;
                    }
                }
            }
            if(count<cate[i].leastnum)
            {
                flag=1;
            }

        }
        if(flag==1)
            cout<<"no"<<endl;
        else
            cout<<"yes"<<endl;
        cin>>k;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator