bored

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5375

 1 #include<stdio.h>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<string.h>
 5 using namespace std;
 6 int main()
 7 {
 8     char s1[10],s2[50];
 9     while(cin>>s1)
10     {
11         cin>>s2;
12         int len1[10],count=0;
13         memset(len1,0,sizeof(len1));
14         int l1=strlen(s1);
15         int l2=strlen(s2);
16         for(int i=0; i<l1; i++)
17         {
18             for(int j=0; j<l2; j++)
19             {
20                 if(s1[i]==s2[j])
21                 {
22                     len1[i]=j;
23                     count++;
24                     s2[j]=' ';
25                     break;
26                 }
27             }
28         }
29 
30         bool flag=true;
31         if(count!=l1)
32             flag=false;
33         else
34         for(int i=1; i<l1; i++)
35         {
36             if(len1[i]<len1[i-1])
37             {
38                 flag = false;
39                 break;
40             }
41         }
42         if(flag)cout<<"PASS"<<endl;
43         else cout<<"FAIL"<<endl;
44         memset(s1,NULL,sizeof(s1));
45         memset(s2,NULL,sizeof(s2));
46     }
47     return 0;
48 }
View Code

这个代码改啦好久,其实没有什么难得,但是却改啦好久,就是因为考虑问题不全面造成的,因为忘记考虑一种情况,就是有可能str1的字符串不能再str2中全部被找到,哎,今天做几道题,信心都被磨没啦,好伤心,但是,站起来,世界就是你的!!! 啊啊啊,加油

转载于:https://www.cnblogs.com/shangjindexiaoqingnian/p/5738639.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值