当前位置:网站首页>2. Average length of words
2. Average length of words
2022-04-23 06:08:00 【linsa_ pursuer】
Each sentence consists of multiple words , The length of each word in the sentence may be different , Give the average word length of the whole sentence
package com;
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println(avg(s.nextLine()));
}
public static String avg(String words){
String[] arr = words.split(" ");
int sum = 0;
for(int i=0;i<arr.length;i++){
sum += arr[i].length();
}
return (new BigDecimal(String.valueOf(sum))).divide(new BigDecimal(String.valueOf(arr.length)), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
}
}
Such as :
Input :Who Love Solo
Output :3.67
版权声明
本文为[linsa_ pursuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533259961.html
边栏推荐
- 线代第四章-向量组的线性相关
- 卡尔曼滤波与惯性组合导航
- Opensips (1) -- detailed process of installing opensips
- Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
- Protected (members modified by protected are visible to this package and its subclasses)
- Rsync for file server backup
- 在Jupyter notebook中用matplotlib.pyplot出现服务器挂掉、崩溃的问题
- Pytorch——数据加载和处理
- 线性代数第二章-矩阵及其运算
- Kingdee EAS "general ledger" system calls "de posting" button
猜你喜欢

Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)

Explain of MySQL optimization

Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering

List segmentation best practices

CONDA virtual environment management (create, delete, clone, rename, export and import)
![去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention](/img/4e/1a51636853d11544e6f5c37a588730.png)
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention

In depth understanding of the relationship between dncblevel and noise denoising in the paper

Opensips (1) -- detailed process of installing opensips

PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox

Create binary tree
随机推荐
Why does the subscript of the array start from 0 instead of 1?
JDBC operation transaction
Algèbre linéaire chapitre 1 - déterminants
How to grow at work
Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
線性代數第一章-行列式
Pytorch learning record (7): skills in processing data and training models
Delete and truncate
Anaconda
Pytorch notes - complete code for linear regression & manual or automatic calculation of gradient code comparison
Latex快速入门
在Jupyter notebook中用matplotlib.pyplot出现服务器挂掉、崩溃的问题
Chapter 4 of line generation - linear correlation of vector systems
Linear algebra Chapter 2 - matrices and their operations
Automatic control (Han min version)
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
String notes
Pytorch learning record (XI): data enhancement, torchvision Explanation of various functions of transforms