Repository navigation
Expand file tree
/
Copy pathSolution.java
More file actions
67 lines (65 loc) · 1.4 KB
/
Copy pathSolution.java
File metadata and controls
67 lines (65 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static int check(String s)
{
String temp="";
s=s.trim();
s=s+" ";
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(c!=' ')
{
temp=temp+c;
}
else
{
if((temp.equals("end-of-file"))||temp.equals("end-of-file."))
{
return 0;
}
else
{
temp="";
}
}
}
return 1;
}
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
int t=1;
String test="",finall="";
int max=1;
while(t==1&&max<=1000)
{
test=sc.nextLine();
t=check(test);
finall=finall+test+"*";
test="";
max++;
}
int count=1;
String s2="";
for(int i=0;i<finall.length();i++)
{
char c=finall.charAt(i);
if(c!='*')
{
s2=s2+c;
}
else
{
System.out.println(count +" "+s2);
s2="";
count++;
}
}
}
}