deletion of array elements

Discussion in 'C' started by arindam.kotal, Nov 25, 2012.

  1. arindam.kotal

    arindam.kotal New Member

    Joined:
    Nov 4, 2012
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    I am doing a program which will delete the duplicate match pair from the matching pair list between two string.It will print all the arrays except those duplicate pairs.
    suppose ,from two given sequence we got the following matching pairs based on their positions
    p[0]=(0,1)
    p[1]=(0,5)
    p[2]=(1,0)
    p[3]=(1,2)
    p[4]=(1,7)
    p[5]=(2,4)
    p[6]=(2,6)
    p[7]=(3,3)
    p[8]=(3,8)
    p[9]=(4,0)
    p[10]=(4,2)
    now,i want to delete the pairs which has the same element,i.e.(0,1)&(1,0) are the pairs which contained the same elements.
    I want to delete(1,0)& like that (4,2).
    the final result should be printed all the matching pairs except (1,0)&(4,2).

    i am trying this i am facing problem...how it is possible in C.
    plz.. help...
     
  2. DRK

    DRK New Member

    Joined:
    Apr 13, 2012
    Messages:
    44
    Likes Received:
    3
    Trophy Points:
    0
    Code:
    #include <stdio.h>
    
    int main()
    {
        const char *p[11];
        int i, j, a[11][2];
        p[0] = "(0,1)";
        p[1] = "(0,5)";
        p[2] = "(1,0)";
        p[3] = "(1,2)";
        p[4] = "(1,7)";
        p[5] = "(2,4)";
        p[6] = "(2,6)";
        p[7] = "(3,3)";
        p[8] = "(3,8)";
        p[9] = "(4,0)";
        p[10] = "(4,2)";
        for (i = 0; i < 11; ++i)
        {
            sscanf(p[i], "(%d,%d)", &a[i][0], &a[i][1]);
            for (j = 0; j < i; ++j)
            {
                if ((a[i][0] == a[j][0] && a[i][1] == a[j][1]) || (a[i][0] == a[j][1] && a[i][1] == a[j][0]))
                {
                    p[i] = NULL;
                }
            }
        }
        for (i = 0; i < 11; ++i)
        {
            if (p[i] != NULL)
            {
                puts(p[i]);
            }
        }
        return 0;
    }
     
  3. arindam.kotal

    arindam.kotal New Member

    Joined:
    Nov 4, 2012
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    thanks DRK for reply...
     
  4. arindam.kotal

    arindam.kotal New Member

    Joined:
    Nov 4, 2012
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    lcs problem

    Let, we have 3 sequences,
    1 2 34 56 7 8 910 11 12
    s1=a c t t c a g g c t a a
    s2=t t c t a a a g c a a t
    s3=a a c c g t a t t c g a
    the method finding 1st relative position of a,g,t,c.
    a=(1,5,1)
    t=(3,1,6)
    g=(7,8,5)
    c=(2,3,3)
    then find Xa=1+5+1,Xt=(3+1+6),Xg=(7+8+5),Xc=(2+3+3)
    Ya=|1-5|+|5-1|+|1-1| thus find for each t,g,c
    Za=Xa+Ya
    then find the minimum Za.here the minimum is Zc.
    then the corresponding charecter will represent the longest common subsequences.
    then, the string is visited from after(2,3,3) 7 the index will have to be started from 1 to find the identical charecterset.
    1 2 34 56 7 8 910 11 12
    s1=a c t t c a g g c t a a
    s2=t t c t a a a g c a a t
    s3=a a c c g t a t t c g a
    if (2,3,3) is the minimum, then the next pair are
    a=(4,2,4),t=(1,1,3),g=(5,5,2),c=(3,6,1)
    I need the the code...to do this.
    I am able to find the 1st minimum pairs but the next step i am unable to do.
    plz help me....
    ,
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice