zoukankan      html  css  js  c++  java
  • UVA 10252

    按照字典序输出最长公共子序列

     1 #include<time.h>
     2 #include <cstdio>  
     3 #include <iostream>  
     4 #include<algorithm>
     5 #include<math.h> 
     6 #include <string.h>  
     7 #include<vector> 
     8 #include<queue>
     9 #include<set>
    10 #include<iterator>
    11 using namespace std;
    12 
    13 
    14 int dp[1005][1005];
    15 char str1[1005],str2[1005]; 
    16 
    17 
    18 int main()
    19 {
    20     int len1,len2,i,j;
    21     while(gets(str1)&&gets(str2))
    22     {
    23         memset(dp,0,sizeof(dp));
    24         len1=strlen(str1);
    25         len2=strlen(str2);
    26         sort(str1,str1+len1);
    27         sort(str2,str2+len2);
    28         
    29         
    30         for(i=0,j=0;i<len1&&j<len2;)//注意这里的&& 
    31         {
    32             if(str1[i]==str2[j])
    33             {
    34                 cout<<str1[i];
    35                 i++;
    36                 j++;
    37             }
    38             else if(str1[i]>str2[j])
    39                 j++;
    40             else
    41                 i++;
    42             
    43         }
    44             
    45         cout<<endl;
    46     }
    47     return 0;
    48  } 
  • 相关阅读:
    通信接收机同步模块
    CAZAC序列
    Verilog Tricks
    载波同步
    Matlab step方法
    CRC校验码
    比特冗余
    Vivado RAM使用
    collection
    hashlib
  • 原文地址:https://www.cnblogs.com/pter/p/5409956.html
Copyright © 2011-2022 走看看