-
Notifications
You must be signed in to change notification settings - Fork 0
/
JAVA.java
80 lines (79 loc) · 2.49 KB
/
JAVA.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class JAVA
{
public static void main(String[] args) throws FileNotFoundException
{
Scanner in;
Random r = new Random();
if(args.length > 0)
{
in = new Scanner(new File(args[0]));
}
else
{
in = new Scanner(System.in);
}
while(in.hasNextLine())
{
String line = in.nextLine().toUpperCase();
String[] words = line.split(" ");
for(int i = 0; i < words.length; i++)
{
int swap_count = 0;
StringBuilder tmp = new StringBuilder(words[i]);
for(int j = 0; j < words[i].length() - 1; j++)
{
if(swap_count < 2 && r.nextInt(100) < 20)
{
swap_count++;
char c = tmp.charAt(j);
tmp.setCharAt(j, tmp.charAt(j + 1));
tmp.setCharAt(j + 1, c);
}
}
words[i] = tmp.toString();
}
for(int i = 0; i < words.length; i++)
{
int max_del = words[i].length() / 5;
int act_del = 0;
StringBuilder tmp = new StringBuilder(words[i]);
for(int j = 0; j < tmp.length(); j++)
{
int prob;
if(j < tmp.length() - 1 && tmp.charAt(j) == tmp.charAt(j + 1))
{
prob = 40;
}
else if(tmp.charAt(j) == 'A' || tmp.charAt(j) == 'E' || tmp.charAt(j) == 'I' || tmp.charAt(j) == 'O' || tmp.charAt(j) == 'U')
{
prob = 5;
}
else
{
prob = 10;
}
if(act_del < max_del && r.nextInt(100) < prob)
{
act_del++;
tmp.deleteCharAt(j);
j--;
}
}
words[i] = tmp.toString();
}
for(int i = 0; i < words.length; i++)
{
System.out.print(words[i] + " ");
}
if(r.nextInt(100) < 30)
{
System.out.print("H!?");
}
System.out.println();
}
}
}