CCF计算机软件能力认证201612前两题java满分解

第一题

package ccf201612;

import java.util.Scanner;

public class p1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int res = -1;
        for (int i = 0; i < n; i++) {
            int max = 0;
            int min = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] != a[i]) {
                    if (a[j] > a[i]) {
                        max++;
                    } else if (a[j] < a[i]) {
                        min++;
                    }
                }
            }
            if (max == min) {
                res = a[i];

            }
        }
        System.out.println(res);
    }
}

第二题

package ccf201612;

import java.util.Scanner;

public class p2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        double S = 0;
        if (T <= 3500) {
            S = T;
        } else if (T <= 4955) {
            S = (T - 3500) / (1 - 0.03) + 3500;
        } else if (T <= 7655) {
            S = (T - 4955) / (1 - 0.1) + 5000;
        } else if (T <= 11255) {
            S = (T - 7655) / (1 - 0.2) + 8000;
        } else if (T <= 30755) {
            S = (T - 11255) / (1 - 0.25) + 12500;
        } else if (T <= 44755) {
            S = (T - 30755) / (1 - 0.3) + 38500;
        } else if (T <= 61005) {
            S = (T - 44755) / (1 - 0.35) + 58500;
        } else {
            S = (T - 61005) / (1 - 0.45) + 83500;
        }
        int res = (int) S;
        System.out.println(res);
    }
}
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值