import java.io.*;
import java.util.*;
public class select {
public static void main(String[] args) {
int j=0,i=0,loc=0,col=0;
String line;int []a=new int[15];
try {
FileReader fr = new FileReader("D:\\abc.txt");
BufferedReader br = new BufferedReader(fr);
while ((line = br.readLine()) != null) {
StringTokenizer st2 = new StringTokenizer(line, " ");
col=0;
while(st2.hasMoreTokens()){
a[j]=st2.nextToken().length();
j++;
col++;
}
i++;
}
br.close();
//First value
int max1=a[0];
for(int l=col-3;l<=a.length-1;l=l+3){
if(max1<a[l]){
max1=a[l];
loc=l;
}
}
int sp1=loc/col;
FileReader fr1 = new FileReader("D:\\abc.txt");
BufferedReader br1 = new BufferedReader(fr1);
for(int k=0;k<sp1;k++){
br1.readLine();
}
if((line = br1.readLine()) != null) {
System.out.println(line);
}
br1.close();
//Second value
int max2=a[1];
for(int l=col-2;l<=a.length-1;l=l+3){
if(max2<a[l]){
max2=a[l];
loc=l;
}
}
int sp2=loc/col;
FileReader fr2 = new FileReader("D:\\abc.txt");
BufferedReader br2 = new BufferedReader(fr2);
for(int k=0;k<sp2;k++){
br2.readLine();
}
if((line = br2.readLine()) != null) {
System.out.println(line);
}
br2.close();
//Third value
int max3=a[1];
for(int l=col-1;l<=a.length-1;l=l+3){
if(max3<a[l]){
max3=a[l];
loc=l;
}
}
int sp3=loc/col;
FileReader fr3 = new FileReader("D:\\abc.txt");
BufferedReader br3 = new BufferedReader(fr3);
for(int k=0;k<sp3;k++){
br3.readLine();
}
if((line = br3.readLine()) != null) {
System.out.println(line);
}
br3.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.util.*;
public class select {
public static void main(String[] args) {
int j=0,i=0,loc=0,col=0;
String line;int []a=new int[15];
try {
FileReader fr = new FileReader("D:\\abc.txt");
BufferedReader br = new BufferedReader(fr);
while ((line = br.readLine()) != null) {
StringTokenizer st2 = new StringTokenizer(line, " ");
col=0;
while(st2.hasMoreTokens()){
a[j]=st2.nextToken().length();
j++;
col++;
}
i++;
}
br.close();
//First value
int max1=a[0];
for(int l=col-3;l<=a.length-1;l=l+3){
if(max1<a[l]){
max1=a[l];
loc=l;
}
}
int sp1=loc/col;
FileReader fr1 = new FileReader("D:\\abc.txt");
BufferedReader br1 = new BufferedReader(fr1);
for(int k=0;k<sp1;k++){
br1.readLine();
}
if((line = br1.readLine()) != null) {
System.out.println(line);
}
br1.close();
//Second value
int max2=a[1];
for(int l=col-2;l<=a.length-1;l=l+3){
if(max2<a[l]){
max2=a[l];
loc=l;
}
}
int sp2=loc/col;
FileReader fr2 = new FileReader("D:\\abc.txt");
BufferedReader br2 = new BufferedReader(fr2);
for(int k=0;k<sp2;k++){
br2.readLine();
}
if((line = br2.readLine()) != null) {
System.out.println(line);
}
br2.close();
//Third value
int max3=a[1];
for(int l=col-1;l<=a.length-1;l=l+3){
if(max3<a[l]){
max3=a[l];
loc=l;
}
}
int sp3=loc/col;
FileReader fr3 = new FileReader("D:\\abc.txt");
BufferedReader br3 = new BufferedReader(fr3);
for(int k=0;k<sp3;k++){
br3.readLine();
}
if((line = br3.readLine()) != null) {
System.out.println(line);
}
br3.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
0 comments:
Post a Comment