java 1>2?a:b
时间: 2023-07-30 21:06:28 浏览: 76
这是一个 Java 中的三目运算符,意思是如果 1 大于 2,则返回 a,否则返回 b。可以写成:
```
result = 1 > 2 ? a : b;
```
如果 1 大于 2,则 result 的值为 a,否则为 b。
相关问题
#include<iostream> using namespace std; const int N = 100; int D[N][N]; int max(int a, int b) { int m = a > b ? a : b; return m; } int fun_d(int i,int j,int n) { if (i == n-1) return D[i][j]; int Sum_L = fun_d(i + 1, j, n); int Sum_R = fun_d(i + 1, j + 1, n); return max(Sum_L, Sum_R)+D[i][j]; } int main() { int n, i, j; cin >> n;//n行数 for (i = 0; i < n; i++) { for (j = 0; j <= i; j++) { cin >> D[i][j]; } } int MaxSum = fun_d(0,0,n); cout << MaxSum << endl; return 0; }改成Java语言代码
下面是将C++代码转换为Java代码的结果:
```java
import java.util.Scanner;
public class Main {
static final int N = 100;
static int[][] D = new int[N][N];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // n行数
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
D[i][j] = sc.nextInt();
}
}
int MaxSum = fun_d(0, 0, n);
System.out.println(MaxSum);
}
static int max(int a, int b) {
int m = a > b ? a : b;
return m;
}
static int fun_d(int i, int j, int n) {
if (i == n-1)
return D[i][j];
int Sum_L = fun_d(i + 1, j, n);
int Sum_R = fun_d(i + 1, j + 1, n);
return max(Sum_L, Sum_R)+D[i][j];
}
}
```
在JSTL核心库中,常用标签不包括 A<c:redirect> B<c:if> C<c:out> D<c:else>
答案是A<c:redirect>。JSTL(JavaServer Pages Standard Tag Library)是一组标签库,用于简化JSP页面中的Java代码。其中常用的标签包括<c:if>、<c:out>、<c:forEach>等等,但<c:redirect>不属于JSTL核心库中的标签。它属于JSTL扩展库中的标签,用于重定向到另一个页面。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)