| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:大牛帮帮忙 怎么老是WA是不是有比较偏的数据没有考虑到啊?谢谢啊In Reply To:大牛帮帮忙 怎么老是WA是不是有比较偏的数据没有考虑到啊?谢谢啊 Posted by:howling at 2011-07-11 18:46:41 > #include<iostream>
> int sub(char ch1[],char ch2[]){
> int len1=strlen(ch1);
> int len2=strlen(ch2);
> int i=0;
> int j=0;
>
> int count=0;
>
> for(i=0;i<len2;i++){
>
> for(j;j<len1;j++){
> if(ch2[i]==ch1[j]){
>
> j++;
> count++;
> break;
> }
> }
>
> }
> if(count==len2){return 1;}
> j=0;
> count=0;
> for(i=len2-1;i>=0;i--){
> for(j;j<len1;j++){
> if(ch2[i]==ch1[j]){
>
> count++;
> j++;
> break;
> }
>
> }
> }
> if(count==len2)return 1;
> else return 0;
>
>
> }
> using namespace std;
> int main (){
> int n;
> char ch1[10],ch2[10];
>
> cin>>n;
> while(n--){
> cin>>ch1>>ch2;
> if(sub(ch1,ch2))cout<<"YES"<<endl;
> else cout<<"NO"<<endl;
> }
> system("pause");
> return 0;
> }
不好意思 无视我 数组开的太小了 鄙视一下自己
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator