Java 1085 PAT单位排行(1)

文章讲述了Java代码实现中解决特定问题的过程,涉及数据结构如HashMap和类的Comparable接口,以及与Kafka技术的集成,包括生产者和消费者的使用,以及Spring框架的整合。主要关注了Kafka的集群配置和基本操作的实现。
摘要由CSDN通过智能技术生成

Java代码实现(未AC,最后2个测试点未通过):

=========================

import java.io.*;

import java.util.*;

public class Main {

public static void main(String[] args) throws NumberFormatException, IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int n = Integer.parseInt(br.readLine());

Map<String,School1085> map = new HashMap<String,School1085>();

for(int i = 0; i < n;i++) {

String[] split = br.readLine().split(" ");

char type = split[0].charAt(0);

double score = Integer.parseInt(split[1]);

if(type == ‘B’) {

score = score / 1.5;

}else if(type == ‘T’) {

score = score * 1.5;

}

String name = split[2].toLowerCase();

School1085 value = map.get(name);

if(value == null) {

School1085 school = new School1085(name, score);

map.put(name, school);

}else {

value.count += 1;

value.sum += score;

}

}

Set keySet = map.keySet();

Iterator iterator = keySet.iterator();

List list = new ArrayList();

while(iterator.hasNext()) {

String key = iterator.next();

School1085 school1085 = map.get(key);

list.add(school1085);

}

Collections.sort(list);

list.get(0).rank = 1;

for(int i = 1; i < list.size();i++) {

if(list.get(i).sumEnd == list.get(i - 1).sumEnd) {

list.get(i).rank = list.get(i - 1).rank;

}else {

list.get(i).rank = i + 1;

}

}

System.out.println(list.size());

for(School1085 data : list) {

System.out.println(data);

}

}

}

class School1085 implements Comparable{

String name;

int count = 1;

int sum;

int rank;

public School1085(String name, double sum) {

this.name = name;

this.sum = (int)sum;

}

@Override

public int compareTo(School1085 o) {

if(this.sum != o.sum) {

return -(this.sum - o.sum);

}else if(this.count != o.count) {

return this.count - o.count;

}else {

return this.name.compareTo(o.name);

}

}

@Override

public String toString() {

return rank + " " + name + " " + sum + " " + count;

}

}

C++代码实现(AC):

============

#include

#include

#include

#include

#include

#include

#include<bits/stdc++.h>

using namespace std;

struct node{

string school;

int sum;

int num;

};

bool cmp(node a,node b)

{

if(a.sum!=b.sum)

return a.sum>b.sum;

else if(a.num!=b.num)

return a.num<b.num;

else

return a.school<b.school;

}

int main(){

int N;

cin>>N;

map<string,double> sc;//学校成绩

map<string,int> sn;//学校人数

for(int i=0;i<N;i++)

{

string no;//准考证号

double score;//成绩

string sch;//学校

cin>>no;

cin>>score>>sch;

for(int j=0;j<sch.length();j++)

{

sch[j]=tolower(sch[j]);

}

Kafka实战笔记

关于这份笔记,为了不影响大家的阅读体验,我只能在文章中展示部分的章节内容和核心截图

image.png

  • Kafka入门
  • 为什么选择Kafka
  • Karka的安装、管理和配置

image.png

  • Kafka的集群
  • 第一个Kafka程序
  • image.png

afka的生产者

image.png

  • Kafka的消费者
  • 深入理解Kafka
  • 可靠的数据传递

image.png

image.png

  • Spring和Kalka的整合
  • Sprinboot和Kafka的整合
  • Kafka实战之削峰填谷
  • 数据管道和流式处理(了解即可)

image.png

  • Kafka实战之削峰填谷

image.png

[外链图片转存中…(img-QeSMxwIk-1714302938339)]

[外链图片转存中…(img-pFlML1GB-1714302938340)]

  • Spring和Kalka的整合
  • Sprinboot和Kafka的整合
  • Kafka实战之削峰填谷
  • 数据管道和流式处理(了解即可)

[外链图片转存中…(img-cpSy6LEQ-1714302938340)]

  • Kafka实战之削峰填谷

[外链图片转存中…(img-4GbVzccP-1714302938340)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值