package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> strings = new ArrayList<String>();
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
String s = sc.nextLine();
strings.add(s);
}
int shortest = strings.get(0).length();
int shortestIndex = 0;
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).length() < shortest)
shortestIndex = i;
shortest = strings.get(i).length();
}
int longest = strings.get(0).length();
int longestIndex = 0;
for (int i = 0; i < strings.size(); i++)
{
if (strings.get(i).length() > longest)
longestIndex = i;
longest= strings.get(i).length();
}
if ( shortestIndex < longestIndex )
System.out.println(strings.get(shortestIndex));
else
System.out.println(strings.get(longestIndex));
}
}
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> strings = new ArrayList<String>();
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
String s = sc.nextLine();
strings.add(s);
}
int shortest = strings.get(0).length();
int shortestIndex = 0;
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).length() < shortest)
shortestIndex = i;
shortest = strings.get(i).length();
}
int longest = strings.get(0).length();
int longestIndex = 0;
for (int i = 0; i < strings.size(); i++)
{
if (strings.get(i).length() > longest)
longestIndex = i;
longest= strings.get(i).length();
}
if ( shortestIndex < longestIndex )
System.out.println(strings.get(shortestIndex));
else
System.out.println(strings.get(longestIndex));
}
}