#6274:


jorge13jorge13 (其實kira95137很厲害)

學校 : 國立彰化高級中學
編號 : 20315
來源 : [140.112.212.87]
最後登入時間 :
2016-10-15 01:51:33
a224. 明明愛明明 | From: [118.233.26.245] | 發表日期 : 2012-02-02 23:00

#include<iostream>
using namespace std;
string a,s;
int n,i,j,t,k;
int main()
{
    while(cin>>s)
    {
        a.clear();
        for(i=0;i<s.length();i++)
        {           
            if(isalpha(s[i])==1)
                a.append(s.substr(i,1));
            else if(isalpha(s[i])==2)
            {
                s[i]-=32;
                a.append(s.substr(i,1));
            }               
        }
        k=2;
        n=a.length();
        if(n==0)
        {
            cout<<"no..."<<endl; 
            continue;
        }
        for(i=0;i<n;i++)
        {
            t=0;             
            if(a.find(a.substr(i,1))<i)
                continue; 
            t++;         
            for(j=i+1;j<n;j++)  
            {              
                if(a.at(i)==a.at(j))
                    t++;               
            }
            if(t%2==1)
            {
                k--;
                if(k==0)
                {
                cout<<"no..."<<endl;               
                break;
                }
            }
        }
        if(k)
            cout<<"yes !"<<endl;         
    }
    return 0;
}

請問這樣有錯嗎?我怎麼會WA(line1)? 

 
ZeroJudge Forum