解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int arr[] = {3,7,5,13,25,45,78,23,8,33,9,19,28,41,50}; int n = scanner.nextInt(); if(n % 2 == 0) { System.out.println("Error"); } else { int i; for(i = 0; i < arr.length; i ++) { if(arr[i] == n) { System.out.println(i + 1); break; } } if(i >= arr.length) { System.out.println("Error"); } } } }
0.0分
0 人评分