-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhe1.java
More file actions
49 lines (39 loc) · 1.27 KB
/
he1.java
File metadata and controls
49 lines (39 loc) · 1.27 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
package practice1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.String;
import java.lang.StringBuilder;
public class he1 {
public static void main(String args[] ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
//System.out.println("hella");
while( (line=br.readLine()) != null)
{
StringBuilder builder = new StringBuilder();
Boolean commented=false;
for(int i=0;i<line.length();++i)
{
//comment
if(line.charAt(i)=='/'&& line.charAt(i+1)=='/')
{
commented=true;
//print the exsting string builder output
System.out.print(builder);
//print the rest of line as it is
System.out.println(line.substring(i));
//get out now
break;
}
//-> case
else if(line.charAt(i)=='-' && line.charAt(i+1)=='>')
{
builder.append('.');
++i;
}
else builder.append(line.charAt(i));
}
if(commented=false) System.out.println(builder);
}
}//main
}