feat(02-nondupl): Добавлено задание

This commit is contained in:
Mark Zheleznyakov
2024-11-07 11:15:12 +03:00
parent 39025d9397
commit 45fff6617b
12 changed files with 486 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.10.2/userguide/building_java_projects.html in the Gradle documentation.
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// This dependency is used by the application.
implementation(libs.guava)
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(23)
}
}
application {
// Define the main class for the application.
mainClass = "ru.mrqiz.nondupl.App"
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
tasks.named<JavaExec>("run") {
standardInput = System.`in`
}

View File

@ -0,0 +1,24 @@
package ru.mrqiz.nondupl;
import java.util.HashMap;
public class App {
public static void main(String[] args) {
HashMap<Integer, Integer> map = new HashMap<>();
for (String arg : args) {
if (!arg.matches("-?\\d+")) {
System.err.println("Not int found, skipping " + arg);
} else {
Integer i = Integer.valueOf(arg);
map.put(i, map.getOrDefault(i, 0) + 1);
}
}
for (Integer number : map.keySet()) {
if (map.get(number) == 1) {
System.out.println(number);
}
}
}
}