Given a sentence as input, calculate and output the average word length of that sentence. To calculate the average word length, you need to divide the sum of all word lengths by the number of words in the sentence. python
Const nx=30;var i,j,p,n:integer;A:array[1..nx,1..nx] of integer;d,Sn,min:real;begin p:=1;write('Введите размер матрицы');Read(n);for i:=1 to n do beginfor j:=1 to n do beginA[i,j]:=random(3)-2;write(A[i,j]:4);end;writeln;end;writeln;writeln;for i:=1 to n do beginfor j:=1 to n do beginif i = j then begin if A[i,j]<> 0 then p:=p* A[i,j];write(A[i,j]:4);endelse write(' ':4);end;writeln;end;write('p =',p);writeln;writeln;for i:=1 to n do beginfor j:=1 to n do beginif (i= n -j +1) then begin if A[i,j]<> 0 then p:=p* A[i,j];write(A[i,j]:4);endelse write(' ':4);end;writeln;end;write('p =',p);end.
Const n = 5; m = 5; var a:array[1..n,1..m] of integer; i,j,s:integer; begin //Для теста заполним массив сл.числами for i:=1 to n do begin for j:=1 to m do begin a[i,j]:=random(21)-10; write(a[i,j]:4); end; writeln;writeln; end; //сумма всех элементов массива for i:=1 to n do for j:=1 to m do s:=s+a[i,j]; writeln('сумма всех элементов массива: ',s); //сумма каждой строки for i:=1 to n do begin s:=0; for j:=1 to m do begin s:=s+a[i,j]; end; writeln ('Строка: ',i,' сумма:',s); end; end.
Учитывая предложение в качестве входных данных, вычислите и выведите среднюю длину слова этого предложения.
Чтобы вычислить среднюю длину слова, вам нужно разделить сумму всех длин слов на количество слов в предложении. питон
Объяснение:
перевод с английского языка на русский