Question: Help needed. Please re-correct my code to print right results. The result I want to print out is blow: but my code can only print
Help needed. Please re-correct my code to print right results. The result I want to print out is blow:

but my code can only print out.

My C code is blow, the code should dynamically print results when matrix and word1,word2 are changing:
#include
int main () {
char matrix[7][9]={{0,1,2,3,4,5,6,7,8,9},{1,0,1,2,3,4,5,6,7,8},{2,1,0,1,2,3,4,5,6,7}, {3,2,1,0,1,2,3,4,5,6},{4,3,2,1,0,1,2,3,4,5},{5,4,3,2,1,1,2,3,4,5},{6,5,4,3,2,2,2,3,3,4}, {7,6,5,4,3,3,3,3,4,4}}; char word1[100]="someone"; char word2[100]="something"; int len1; int len2; len1=strlen(word1); len2=strlen(word2); char path1[100]; char path2[100]; char cost[100]; int i,j;
int max(int a,int b) { return a>b?a:b; } for(i=0;i
}
if((matrix[i][j]==matrix[i-1][j]+1)&&(matrix[i][j]!=matrix[i-1][j-1]+1)) { path1[max(i,j)-1]=word1[i-1]; path2[max(i,j)-1]='-';
} if((matrix[i][j]==matrix[i][j-1]+1)&&(matrix[i][j]!=matrix[i-1][j-1]+1)&&(matrix[i][j]!=matrix[i-1][j]+1)) { path1[max(i,j)-1]='-'; path2[max(i,j)-1]=word2[j-1];
} }
} printf("Alignment: ");
for(i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
