Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions string_lab5_a.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class string_lab5_a {
public static void main(String[] args) {
Scanner sin=new Scanner(System.in);
String str,str_all="";
System.out.println("������� ���� �����.\n��� ������ �� ��������� ����� �������� exit\n");
System.out.println("������� ���� �����.\n��� ������ �� ��������� ����� �������� exit\n");
/*while((str=sin.nextLine())!="exit\n")
{
str_all+=str;
Expand All @@ -16,19 +16,18 @@ public static void main(String[] args) {
str_all=str_all.replace("!","");
str_all=str_all.replace("?","");
String str_mas[]= str_all.split(" ");
String vowel_mas[]={"�","�","�","�","�","�","�","�","�","�"};
String vowel_mas[]={"�","�","�","�","�","�","�","�","�","�"};
double ratio_mas[]=new double[str_mas.length];

for(int i=0;i<str_mas.length;i++)
{
int n=str_mas[i].length();
int vowel=0;
for(int k=0;k<10;k++)
if(str_mas[i].contains(vowel_mas[k]))
{
vowel++;
}
ratio_mas[i]=vowel/str_mas[i].length();
//Memory expensive way, but nice and simple code: - count how many times contains
vowel += str_mas[i].split(vowel_mas[k]).length - 1;
// type conversion before '/'
ratio_mas[i]=((double)vowel)/str_mas[i].length();
}

for(int i=0;i<str_mas.length-1;i++)
Expand Down