def sort(num, type): x=0 y=0 while num> 0: iftype == 0: X= y+2 num-- elif type == 1:x=y+10 num-- else: x=y+20 num-- return X转为java
时间: 2024-05-23 12:12:17 浏览: 162
public int sort(int num, int type) {
int x = 0;
int y = 0;
while (num > 0) {
if (type == 0) {
x = y + 2;
num--;
} else if (type == 1) {
x = y + 10;
num--;
} else {
x = y + 20;
num--;
}
}
return x;
}
阅读全文