Common Subsequence 1458 pku
来源:互联网 发布:offcf2007修复软件 编辑:程序博客网 时间:2024/05/16 05:39
#include<iostream>
#include<string.h>
using namespace std;
int exportMax(int a,int b)
{
return a>b? a:b;
}
int opt[1010][1010];
int main()
{
char str1[1010],str2[1010];
while(cin>>str1+1>>str2+1)
{
int len1=strlen(str1+1);
int len2=strlen(str2+1);
memset(opt,0,sizeof(opt));
for(int i=1;i<=len1;i++)
{
for(int j=1;j<=len2;j++)
{
if(str1[i]==str2[j])
{
opt[i][j]=opt[i-1][j-1]+1;
}
else
{
opt[i][j]=exportMax(opt[i-1][j],opt[i][j-1]);
}
}
}
cout<<opt[len1][len2]<<endl;
}
}
总结下:1.注意字符串从0开始而下标从1开始,所以。。。。
2.opt[1010][1010]放在main外面,否则会ruantime error
- pku 1458 Common Subsequence
- Common Subsequence 1458 pku
- Common Subsequence 1458 pku
- Common Subsequence(PKU 1458)
- Pku acm 1458 Common Subsequence
- PKU 1458 HDOJ 1159 Common Subsequence
- Pku acm 1458 Common Subsequence 题意分析
- Pku acm 1458 Common Subsequence 动态规划解析
- PKU-1458 Common Subsequence (最长公共子序列LCS)
- Pku acm 1458 Common Subsequence 动态规划题目解题报告(五)
- Pku acm 1458 Common Subsequence 动态规划解析 2d1d问题
- Common Subsequence--poj--1458
- poj 1458 Common Subsequence
- poj 1458 Common Subsequence
- Poj 1458 Common Subsequence
- POJ 1458 Common Subsequence
- poj 1458 Common Subsequence
- poj 1458 Common Subsequence
- sql语句教程
- 关于 Exists 的几种嵌套查询
- JavaScript之‘联系我们’,‘收藏本站’,‘设为首页’
- 《浅析pc机上如何将vmlinuz- 2.6.31-14-generic解压出vmlinux》
- ADO操纵数据库封装类
- Common Subsequence 1458 pku
- 编写字符串复制函数strcpy及memcpy函数
- vmalloc函数实现细节
- .Access Insert Into 语法错误 集锦
- 康拓展开
- #include 用这个头文件之前还要做什么设置吗。。
- linux的highmem高端内存是如何被使用的
- 如何用SQL设置一张表中所有的字段允许为空值?
- Ruby on rails Mysql::Error: query: not connected