【发布时间】:2021-09-09 07:07:48
【问题描述】:
我需要帮助编写一个程序,下面必须测试 8 组安全代码的准确率,每组包含 10 个 java 中的整数值(数据结构)
public class lab_three_solution {
/* Solution method: Complete this method only. Also add a relevant parameter to this method*/
public static void compare(){
}
/* Main method: Pass the Security Codes as an argument when calling the 'compare' method */
public static void main(String args[]) {
// 8 Security Codes to compare
int[][] security_codes = {{0,1,1,7,7,2,2,5,0,3}, {5,1,4,0,5,0,9,8,7,5}, {9,8,3,4,0,9,6,7,7,1},
{5,9,5,7,1,4,9,7,6,9}, {7,1,1,4,6,7,9,1,1,0}, {6,1,1,6,3,1,4,7,7,1}, {6,1,1,8,4,9,7,0,1,2},
{9,5,4,6,3,1,4,7,2,9}};
compare(security_codes);
}
}
通过将 8 个代码中每个代码的序列与 如下所示的正确代码序列
正确 = {6,1,1,6,3,1,4,7,7,1}
我必须在 JAVA 中设计和实现一个算法,将准确度打印为 通过将 8 个安全代码中的每一个与 1 个可接受代码进行比较得出的百分比。即如果 说安全代码6序列匹配可接受代码的序列然后我的输出 应该是“安全代码 1 是 100% 准确的”
【问题讨论】:
-
准确率是通过匹配项除以数组中的总项计算得出的吗?
-
好的,这样我们就可以得到百分比的答案
-
您需要哪些具体帮助?你试过什么?它做了什么不符合你的预期?你做了什么来尝试解决这个问题?
-
我已经在 compare() ``` public static void compare(){ int[] code = {6,1,1,6,3,1,4,7,7 ,1};布尔测试=假; for(int element : code){ if(elemet == security_codes) test = true;休息; } }```
标签: java arrays algorithm data-structures