POJ 3080 Blue Jeans

Source: Internet
Author: User

Links: Poj 3080

Test Instructions : Enter n DNA sequences, each of which has a DNA sequence length of 60.

Find the longest co-owned subsequence of these strings.

Note : if not found. or the oldest sequence length is less than 2, the output is no significant commonalities, otherwise the longest common substring is output. if the length of the same output dictionary order of the smallest

ideas : Violent enumeration of each subsequence of the first DNA sequence, matched with the rest of the sequence with the STRSTR () function

Strstr (s,t) is to find the T string in the s string, and if found, returns the address of the first character in S where the T-string appears. If not found, returns null


#include <stdio.h> #include <string.h>char t[65],ans[65];void cmp () {if (strlen (ans) <strlen (t)) STRCP    Y (ans,t); else if (strlen (ans) ==strlen (t)) if (strcmp (ans,t) >0) strcpy (ans,t);}    int main () {int n,m,i,j,k,a;    Char s[12][65];    scanf ("%d", &n);        while (n--) {scanf ("%d", &m);        for (i=0;i<m;i++) scanf ("%s", S[i]);        ans[0]=0;            for (i=0;i<60;i++) {//substring starting from position I k=0;        for (j=i;j<60;j++) {t[k++]=s[0][j];               Add a character t[k]=0 each time after the previous substring; Remember to add the empty character for (a=1;a<m;a++) at the end of the substring//to infer if the remaining string includes the substring if (strstr (s[a],t) ==n                ULL) break;            if (A==M) CMP ();        }} if (strlen (ans) >=3) printf ("%s\n", ans);    else printf ("no significant commonalities\n"); } return 0;}


Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

POJ 3080 Blue Jeans

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.