說明:第二行的數 +30,接著計算該數大於等於第一行數列中的數有幾個。
Java 版
import java.util.Scanner;
public class B138 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
int [] high = new int [10];
for(int a = 0; a < 10; a++)
high[a] = in.nextInt();
int tall = in.nextInt();
tall += 30;
int c = 0;
for(int b = 0; b < 10; b++){
if(tall >= high[b])
c++;
}
System.out.println(c);
}
}
}
Python 版 (2022.07)while True:
try:
high = list(map(int, input().split(' ')))
tall = int(input()) + 30
c = 0
for i in range(10):
if tall >= high[i]:
c += 1
print(c)
except:
break
沒有留言:
張貼留言