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

一次AC 贴代码,庆祝一下

Posted by ZXL_AC at 2015-04-14 20:51:01 on Problem 1035
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> v;
int main()
{
    while(1)
    {
        string s;
        cin>>s;
        if(s == "#") break;
        v.push_back(s);
    }
    while(1)
    {
        string s;
        cin>>s;
        if(s == "#") break;
        cout<<s;
        int p = 0;
        int it = 0;
        for(int i = 0;i < v.size(); i++)
            if(v[i] == s) it = 1;
        if(it)
        {
            cout<<" is correct"<<endl;
            continue;
        }
        cout<<": ";
        for(int i = 0; i < v.size(); i++)
        {
            int minLen = v[i].length() - s.length();
            if(minLen < -1 || minLen > 1) continue;
            int di = 0;
            if(minLen == 0)
            {
                for(int t = 0; t < s.length();t++)
                   if(v[i][t] != s[t])  di++;
               if(di == 1)  cout<<v[i]<<" ";
            }
            if(minLen == 1 || minLen == -1)
            {
                if(minLen == -1)
                {
                    int j = 0;
                    for(int t = 0; t < s.size(); t++)
                    {
                        if(s[t] == v[i][j])
                        {
                            j++;
                        }
                    }
                    if(j == v[i].size())
                        cout<<v[i]<<" ";

                }
                 if(minLen == 1)
                {
                    int j = 0;
                    for(int t = 0; t < v[i].size(); t++)
                    {
                        if(v[i][t] == s[j])
                        {
                            j++;
                        }
                    }
                    if(j == s.size())
                        cout<<v[i]<<" ";
                }
            }
        }
        cout<<endl;
    }
    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