计算点积

This commit is contained in:
Yucheng Hu 2018-12-15 14:25:17 -05:00 committed by YuCheng Hu
parent 21204ebbc1
commit 4ec06517c0
No known key found for this signature in database
GPG Key ID: 1E5CBEF8B550FB7D
1 changed files with 17 additions and 3 deletions

View File

@ -27,9 +27,23 @@ public class LintCode1480DotProductTest {
@Test
public void testMain() {
logger.debug("BEGIN");
int t = 87;
int[] dur = { 20, 25, 19, 37 };
// Write your code here
int[] A = { 1, 1, -1 };
int[] B = { 2147483647, 1, 3 };
int retStatus = 0;
// LENGTH CHECK
if (A.length == 0 || B.length == 0 || A.length != B.length)
retStatus = -1;
// ADDED
if (retStatus != -1) {
for (int i = 0; i < A.length; i++) {
retStatus = retStatus + A[i] * B[i];
}
}
System.out.println(retStatus);
}
}