Jump to content
Fórum Script Brasil
  • 0

Alguém pode me ajudar a fazer esse programa funcionar?


ana.bela2015

Question

Não entendo nada de Java, mas preciso muito fazer esse programa funcionar, porque preciso da matriz que ele faz.
Não ta rodando, acho que está incompleto.
String a ="GATTACA";
String b = "GCATGCA";
int gap = -1
substitution= -1
match = 1;
int[][] opt = new int[a.length() + 1][b.length() + 1];
for (int i = 1; i <= a.length(); i++)
opt[0] = opt[i-1][0] + gap;
for (int j = 1; j <= b.length(); j++)
opt[0][j] = opt[0][j - 1] + gap;
for (int i = 1; i <= a.length(); i++) {
for (int j = 1; j <= b.length(); j++) {
int costDiag;
if ((a.charAt(i-1) == b.charAt(j-1))
scoreDiag= opt[i-1][j-1] + match;
else
scoreDiag= opt[i-1][j-1] + substitution;
int costLeft = opt[j-1] + gap;
int costUp = opt[i-1][j] + gap;
opt[j] = Math.min(Math.min(costDiag, costLeft), costUp);
}
}
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...