如何从一组输入中选择输入? [英] How to select an input from a set of inputs?

查看:70
本文介绍了如何从一组输入中选择输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我确实需要向你们咨询我的java作业。

请指导我如何制作算法从一组输入中选择一个输入?


假设我有一个程序p(a),一个输入a = 1,一组输入= {0,1,2,3,4,5,6,7,8,9,10}。这是程序:


int a = 1

if(a< 5){

System.out.println( " if-1:True");

if(a< 3){

System.out.println(" if-2:True"); }

else {System.out.println(" if-2:False"); }

System.out.println(" a:" + a); }

else {

System.out.println(" if-1:False");

if(a< 8)< br $>
{

System.out.println(" if-3:True"); }

else {

System.out.println(" if-3:False"); }

System.out.println(" a:" + a); }


我该怎么办?

与设置这些输入有关的任何事情都存储在一个文件中,程序首先读取文件以使所有候选人都进入一个列表?


注意:因为之后我需要从集合中选择一个输入来强制执行不同的分支。


谢谢你们......

Hi All,
I do really need to consult you guys about my java assignment.
Please guide me how to make an algorithm to select an input from a set of inputs?

Suppose I have a program p (a), an input a=1, a set of inputs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. This is the program:

int a=1
if(a<5) {
System.out.println("if-1: True");
if(a<3) {
System.out.println("if-2: True"); }
else {System.out.println("if-2: False"); }
System.out.println("a:" +a); }
else {
System.out.println("if-1: False");
if(a<8)
{
System.out.println("if-3: True"); }
else {
System.out.println("if-3: False"); }
System.out.println("a:" +a); }

How am I supposed to do?
Anything to do with set those inputs is stored in a file and the program first read the file to get all candidates into a list?

Note: Because later I need to select an input from the set to force a different branch of execution.

Thanks guys....

推荐答案


大家好,

我确实需要向你们咨询我的java作业。

请指导我如何制作算法从一组输入中选择一个输入?


假设我有一个程序p(a),一个输入a = 1,一组输入= {0,1,2,3,4,5,6,7,8,9,10}。这是程序:


int a = 1

if(a< 5){

System.out.println( " if-1:True");

if(a< 3){

System.out.println(" if-2:True"); }

else {System.out.println(" if-2:False"); }

System.out.println(" a:" + a); }

else {

System.out.println(" if-1:False");

if(a< 8)< br $>
{

System.out.println(" if-3:True"); }

else {

System.out.println(" if-3:False"); }

System.out.println(" a:" + a); }


我该怎么办?

与设置这些输入有关的任何事情都存储在一个文件中,程序首先读取文件以使所有候选人都进入一个列表?


注意:因为之后我需要从集合中选择一个输入来强制执行不同的分支。


谢谢你们....
Hi All,
I do really need to consult you guys about my java assignment.
Please guide me how to make an algorithm to select an input from a set of inputs?

Suppose I have a program p (a), an input a=1, a set of inputs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. This is the program:

int a=1
if(a<5) {
System.out.println("if-1: True");
if(a<3) {
System.out.println("if-2: True"); }
else {System.out.println("if-2: False"); }
System.out.println("a:" +a); }
else {
System.out.println("if-1: False");
if(a<8)
{
System.out.println("if-3: True"); }
else {
System.out.println("if-3: False"); }
System.out.println("a:" +a); }

How am I supposed to do?
Anything to do with set those inputs is stored in a file and the program first read the file to get all candidates into a list?

Note: Because later I need to select an input from the set to force a different branch of execution.

Thanks guys....



再次尝试解释,如果你需要发布代码,请使用代码标签。

Try explaining again and if you need to post code, please do so using code tags.


Ops抱歉模式...

让我再解释一次问题。


假设我有一个测试驱动程序 - TestDriver.java,它存储了一组测试输入,如下所示:
Ops sorry mode...
Let me explain again my problem.

Let say I have a test driver - TestDriver.java which stores and a set of test inputs such this :
展开 | 选择 | Wrap | 行号


可能此代码可以帮助您:

May be this code will help you :

展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于如何从一组输入中选择输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆