我有一个二维整数数组和一个二维双数组。如果double数组中的值小于二维数组的相同位置处的整数值,则在布尔数组的该部分中,值将为true
。如果它更大,那么布尔值将是false
。
我将如何解决这个问题?
这是我到目前为止所尝试的:
public static boolean[][] CompareIntDouble(int[][] pizza, double[][] pasta) {
boolean x = true;
for (int hotdog=0; hotdog < pizza.length; hotdog++) {
for (int toast=0; toast < pizza[hotdog].length; toast++) {
pizza[hotdog][toast] = hotdog * 10 + toast;
if (pasta[1][1] > pizza[1][1]) {
x = true;
} else {
x = false;
}
if (pasta[1][2] > pizza[1][2]) {
x = true;
} else {
x = false
}
}
}
}
答案 0 :(得分:0)
public static void main(String... args) throws IOException {
int[][] t1 = new int[2][2];
t1[0][0] = 0;
t1[0][1] = 1;
t1[1][0] = 2;
t1[1][1] = 3;
double[][] t2 = new double[2][2];
t2[0][0] = 3;
t2[0][1] = 2;
t2[1][0] = 1;
t2[1][1] = 0;
boolean[][] f = new boolean[2][2];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
if (t1[i][j] > t2[i][j]) {
f[i][j] = true;
} else {
f[i][j] = false;
}
System.out.println(i+" "+j+" :"+f[i][j]);
}
}
}
即使你应该先自己尝试一下这里有一个有效的例子
答案 1 :(得分:0)
假设2d输入数组具有相同的大小
use App\user;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class guestController extends Controller
{
public function __construct() { $this->middleware('guest'); }
use SendsPasswordResetEmails;
public function sendPasswordEmail(request $request)
{
$a=user::where('email',Request('email'))->first();
if(count($a)>0){
$this->sendResetLinkEmail($request);
return redirect('password/emailThankyou');
} else {
return redirect()->back();
}
}