Introduction to the classic algorithm contest (second edition) 3-7DNA sequence UVA1368

Beginning to understand the meaning of problems wrong, do for a long, somewhat strenuous

https://vjudge.net/problem/UVA-1368

#include<stdio.h>
#include<string.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--) 
    {
        int m,n,sum=0;
    scanf("%d%d",&m,&n);
    while(m<4||m>50||n<4||n>1000)
    {
        printf("input again\n");
        scanf("% D% D " , & m, & n-); 
    } 
    
    char A [m] [n-]; // dimensional array holding the input DNA sequence 
    
    for ( int X = 0 ; X <m; X ++ ) 
        { 
            Scanf ( " % S " , A [X]); // the gets (A [I]); not less than a first row of the array acquiring 
        } 
    the printf ( " optimal solution \ n- " );    
     for ( int I = 0 ; I <n- ; I ++) // first column loop 
    {
         int B [ . 4 ] = { 0 };
         for (int j=0;j<m;j++)
        {
            //printf("%c\n",a[j][i]); 
            switch(char(a[j][i]))
            {
                case 'A': {b[0]++;//printf("----%d\n",b[0]);
                    break;
                }
                case 'C': {b[1]++;//printf("----%d\n",b[1]);
                    break;
                }
                case 'G':{b[2]++;//the printf ( "% D ---- \ n-", B [2]); 
                    BREAK ; 
                } 
                Case  ' T ' : {B [ . 3 ] ++; // the printf ( "% D ---- \ n-", B [. 3]); 
                    BREAK ; 
                } 
            } 
        } 
    //     for (int the Y = 0; the Y <. 4; the Y ++)
     //     {the printf ( "[D%] =% D", the Y, B [the Y]);} // test whether the assignment is correct array 
        int max = B [ 0 ], K, In Flag = 0 ;
         for (K = . 1 ; K < . 4 ; K ++ ) 
        { 
            iF (B [K]> max)  
            {
                max = B [K]; 
                In Flag = K; 
            } 
            
            
        } 
    //     the printf ( "B = max [D%] =% D", In Flag, max); // test whether the right to take a maximum value 

        Switch (In Flag) 
        { 
            Case  0 : {the printf ( " A " );
                 BREAK ; 
            } 
            Case  . 1 : {the printf ( " C " );
                 BREAK ; 
            } 
            Case  2 : {the printf ( " G " );
                 BREAK ;
            }
            case 3 :{printf("T");
                break;
            }
            
        } 
        sum+=m-max; 
    }
    printf("\nMin=%d\n\n",sum);
}
}
/*
    while(1)
    {
    int m,n;
    scanf("%d%d",&m,&n);
    if(m<4||m>50||n<4||n>1000)
    {
        printf("input again\n");
        scanf("%d%d",&m,&n);
    }
    
    
        char a[m][n+1];
        for(int i=0;i<m;i++)
        {
            scanf("%s",a[i]);//gets(a[i]);不行 第一行数组获取不到 
        }

    for(int j=0;j<m;j++) 
    {
        int count=0;
        //char temp;
        for(int k=0;k<n;k++)
        {
            for(int p=0;p<m;p++)
            {
                if(p==j) {
                    printf("key");
                    continue; 
                }
            else if(a[j][k]==a[p][k])
            {
                count++;
                printf("yes");
                }
                else{printf("no");
                }    
            }            
        }
        printf("count=%d\n",count);
            a[j][n]=count+48; //把数字变为对应字符 
    }
    
    int max=0;
    for(int x=0;x<m-1;x++)
    {
        if(int(a[x+1][n])>int(a[x][n]))
        {
        max=x+1;    
        }
        
        
    }
    printf("max=%d  %c\n",max,a[max][n]);
    
    for(int y=0;y<n;y++)
    {
        printf("%c",a[max][y]);
        
    }//printf("\n%s",a[max]);    
    }
*/ 
    

 
        

 

Guess you like

Origin www.cnblogs.com/lytuser/p/11707156.html