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);
    }
}

 

©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页