java - 处理:如何使一个函数找到我的数组的二次公式的结果?
问题描述
我有一个任务要做,不知道怎么做。
给出的是一个二次方程:
y = a*x*x + b*x + c
到目前为止,这就是我的代码:
void setup(){
println(quadratic(4, 6, 1));
}
float quadratic(float a, float b, float c){
return (-b + sqrt( b*b - 4*a*c)) / (2*a);
}
我必须编写一个函数,将系数作为参数,将结果作为数组。
我只是不知道如何制作一个数组。
非常感谢你!
解决方案
我建议在谷歌上搜索“处理数组”或“Java 数组”之类的内容以获得大量结果。
处理参考是一个很好的起点。这是 Processing 中数组的参考,它包含如下示例代码:
int[] numbers = new int[3];
numbers[0] = 90; // Assign value to first element in the array
numbers[1] = 150; // Assign value to second element in the array
numbers[2] = 30; // Assign value to third element in the array
int a = numbers[0] + numbers[1]; // Sets variable 'a' to 240
int b = numbers[1] + numbers[2]; // Sets variable 'b' to 180
无耻的自我推销:这里有一个关于Processing中的数组的教程。
推荐阅读
- java - Kafka生产者和消费者问题
- c++ - 如何在每个共享库中使用自己的静态库副本
- android - 使用终端命令构建 Android Apk 时出错
- python - 在神经网络中,如果输入 > 1 或 < -1,那么是否应该在传播之前应用激活函数?
- php - $request->all() 始终为空
- amazon-web-services - 如何对 AWS DynamoDB for AWS CLI 进行速率限制扫描?
- python - 清理不需要的scrapy结果行
- javascript - 如何在打字效果中显示输入的文本以及一些常量文本?
- spring-mvc - 即使我正在使用 Controller 注释,我也没有发现任何处理程序异常
- css - 字体显示未知属性 wordpress GoDaddy