java期末考试(OJ)

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int data[] = new int[10];
        String s = sc.nextLine();
        for(int i=0;i<s.length();i++){
            int c = s.charAt(i)-'0';
            data[c]++;
        }
        int flag = 0;
        for(int i=0;i<10;i++){
            if(data[i]!=0)
                flag = 1;
            if(data[i]==0&flag == 0)
                continue;
            System.out.print(data[i]);
        }

    }
}


import java.util.*;
class Furniture{
    int length;
    int width;
    int height;

    public int getLength() {
        return length;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    Furniture(int a, int b, int c){
        length = a;
        width = b;
        height = c;
    }
    
}
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Furniture f = new Furniture(sc.nextInt(),sc.nextInt(),sc.nextInt());
        System.out.println(f.getHeight());
        System.out.println(f.getLength());
        System.out.println(f.getWidth());
    }
}

class CellPhone{
    String xinghao;
    int neicun;
    int cunchu;
    int price;
    CellPhone(String s,int a,int b,int c){
        xinghao = s;
        neicun = a;
        cunchu = b;
        price = c;
    }
    @Override
    public boolean equals(Object o){
        CellPhone a = (CellPhone)o;
        if(xinghao.equals(a.xinghao)&&neicun==a.neicun&&cunchu==a.cunchu){
            return true;
        }else{
            return false;
        }

    }
    @Override
    public String toString(){
        return "CellPhone [model:"+xinghao+", memory:"+neicun+", storage:"+cunchu+", price:"+price+"]";
    }
}

abstract class Vehicle{
    public abstract double getZaizhong();
}
class Truck extends Vehicle{
    double load;
    Truck(double a){
        load = a;
    }
    @Override
    public double getZaizhong() {
        return load*1000;
    }
}
class Keche extends Vehicle{
    int seats;
    Keche(int a){
        seats = a;
    }
    @Override
    public double getZaizhong() {
        return seats*50;
    }
}
class Car extends Vehicle{
    int level,year;
    Car(int a,int b){
        level = a;
        year = b;
    }
    @Override
    public double getZaizhong() {
        return 200*level/Math.sqrt(year);
    }
}
class CarRentCompany{
    public static double rentVehicles(Vehicle[] vs){
        double sum = 0;
        for(int i=0;i<vs.length;i++){
            sum+=vs[i].getZaizhong();
        }
        return sum;
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int a = s.length()%5+1;
        //System.out.println(a);
        String ss= "";
        int i=0;
        while(i*a<s.length()){
            ss+=s.charAt(i*a);
            i++;
        }
        System.out.println(new StringBuffer(ss).reverse().toString());
    }


}


class CourseManagementSystem{
    static Map<Integer,Integer> m;
    CourseManagementSystem(){
        m = new HashMap<Integer,Integer>();
    }
    public void add(int no, int grade){
        if(m.containsKey(no)){
            System.out.println("the student already exists");
        }else {
            m.put(no, grade);
        }
    }
    public void delete(int no){
        if(m.containsKey(no)){
            m.remove(no);
        }else
            System.out.println("no such student");
    }
    public int query (int no){
            return m.get(no);
    }
    public static void statistic(){
        int a=0,b=0,c=0,d=0,e=0;

        for(Integer i:m.keySet()) {
            int grade = m.get(i);
            if(grade >=90&&grade<=100)
                a++;
            else if(grade>=80&&grade<=89)
                b++;
            else if(grade>=70&&grade<=79)
                c++;
            else if(grade>=60&&grade<=69)
                d++;
            else
                e++;
        }
        System.out.println("[0-59] : "+e);
        System.out.println("[60-69] : "+d);
        System.out.println("[70-79] : "+c);
        System.out.println("[80-89] : "+b);
        System.out.println("[90-100] : "+a);
    }
}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值