水题,就求下字符串公共前缀,然后把剩下的加下。。感觉今天水题刷太多了,大脑已经完全不会思考了,碰到难的就跳过。。水平没啥进展啊,算鸟,把能刷的水题先刷光吧。。
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, t;
char *s1 = malloc(81 * sizeof(char));
char *s2 = malloc(81 * sizeof(char));
scanf("%d", &n);
while (n--)
{
scanf("%d", &t);
getchar();
gets(s1);
gets(s2);
char *t1 = s1;
char *t2 = s2;
while (*t1 == *t2 && *t1 != '\0' && *t2 != '\0')
{
t1++;
t2++;
}
int total = 0;
while (*t1++ != '\0')
total++;
while (*t2++ != '\0')
total++;
printf("%d\n", total * t);
}
free(s1);
free(s2);
return 0;
}