第三届蓝桥杯软件大赛java本科组预赛完整答案(完整)
本答案仅供参考,如有不同意见属正常。希望本文对您的学习有帮助!谢谢参阅!
结果填空题
1.
public class first { } 2.
public class two { public static void main(String[] args) {
// TODO Auto-generated method stub int a,b,c; int d = 20; b = 1; c = 1;
double sum = 0; while(d>4) {
private static double result;
public static void main(String[] args) { }
int i[] = new int[100]; i[0] = 1; i[1] = 3;
String string2 = \;
for(int j = 2;j < 30;j++) { }
i[j] = i[j-1] + i[j-2];
result = (double)i[j-1]/i[j];
string2 = new Double(result).toString(); System.out.print(i[j-1]+\+i[j]+\\); System.out.println(string2);
for(a = 1;a <= d;a++) { b = a+1;
while(b while(c <= d-1) { sum = 1.0/d+1.0/a +1.0/b +1.0/c; //System.out.println(sum); if(sum == 1) System.out.println(d+\+a+\ // System.out.print(\ c++; } b++; } } d--; } } } 3. public class three { public static void main(String[] args){ double a[] = new double[65]; a[0] = 1; a[1] = 1; a[2] = 3; a[3] = 7; for(int i = 4;i <= 64 ; i++) a[i] = a[i-1]*2 + 1; System.out.println(\结果为:\+a[64]); } } 4. +b+\+c); public class four { { static int score = 10; public static void main(String[] args) { int a[] = {0,1}; //对或错1、0 int i = 0; for(int x1:a) for(int x2:a) for(int x3:a) for(int x4:a) for(int x5:a) for(int x6:a) for(int x7:a) for(int x8:a) for(int x9:a) for(int x10:a) int result[] for(int z = {x1,x2,x3,x4,x5,x6,x7,x8,x9,x10}; =0;z<=9;z++) { if(result[z]==1) else score = right(z+1); score = wrong(z+1); } if(score == 100) { for(int q = { 0;q<=9;q++) System.out.print(result[q]); } } System.out.println(); i++; } } } static int right(int num) { if(num == 1) score = 10; score = score*2; return score; } static int wrong(int num) { } if(num == 1) score = 10; score = score - num; return score; 代码填空题: 1. import java.util.Scanner; public class B21 { } public static int getFirstNum(String s) { if(s==null || s.length()==0) return -1; public static void main(String[] args) { // TODO Auto-generated method stub Scanner reader = new Scanner(System.in); String string = reader.nextLine(); System.out.println(getFirstNum(string)); } 2. char c = s.charAt(0); if(c>='0' && c<='9') return Integer.parseInt(String.valueOf(c)); //填空 return getFirstNum(s.substring(1)); //填空 } public class B22 { } 3. import java.util.*; public class B23 { public static List if(lst.size()<=5) return lst; int a = lst.remove(lst.size() - 1); // 填空 //System.out.println(a); public static void main(String[] args) { System.out.println(\标准 \ + Math.PI); double a = 1; int n = 6; for(int i=0; i<10; i++) { double b = Math.sqrt(1-(a/2)*(a/2)); a = Math.sqrt((1-b)*(1-b) + (a/2)*(a/2)); n =2*n; //填空 System.out.println(n + \ +a*n/2); // 填空 } }