当前位置:网站首页>6.Reversal
6.Reversal
2022-04-23 06:08:00 【linsa_ pursuer】
Enter an English sentence , The sentence contains several words , There is a space between each word . Now you need to reverse every word in the sentence , Then output the sentence after word inversion ( Don't change the order of the previous words )
Input : There is only one line , Include a length that does not exceed 100 String S, Express English sentences .
Output : There is only one line , That is, output the processed English sentences as required .
sample input :Who Love Solo
sample output :ohW evoL oloS
package com;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println(words(s.nextLine()));
}
public static String words(String words){
StringBuilder wordsReturn = new StringBuilder();
StringBuilder word = new StringBuilder();
String[] arr = words.split(" ");
for(int i=0;i<arr.length;i++){
word.delete(0,word.length());
for(int j=arr[i].length()-1;j>=0;j--){
word.append(arr[i].charAt(j));
}
if(i==0){
wordsReturn.append(word.toString());
}else{
wordsReturn.append(" ");
wordsReturn.append(word.toString());
}
}
return wordsReturn.toString();
}
}
版权声明
本文为[linsa_ pursuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220533259807.html
边栏推荐
- Pytorch learning record (7): skills in processing data and training models
- Pytorch——数据加载和处理
- CONDA virtual environment management (create, delete, clone, rename, export and import)
- SQL optimization best practices
- 去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
- Pytorch学习记录(十一):数据增强、torchvision.transforms各函数讲解
- Dva中在effects中获取state的值
- The attendance client date of K / 3 wise system can only be selected to 2019
- Ptorch learning record (XIII): recurrent neural network
- 線性代數第二章-矩陣及其運算
猜你喜欢
Algèbre linéaire chapitre 1 - déterminants
RPC must know and know
PyEMD安装及简单使用
The user name and password of users in the domain accessing the samba server outside the domain are wrong
解决报错:ImportError: IProgress not found. Please update jupyter and ipywidgets
Framework analysis 1 Introduction to system architecture
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
Pytoch learning record (x): data preprocessing + batch normalization (BN)
Create binary tree
Pytorch learning record (III): structure of neural network + using sequential and module to define the model
随机推荐
Dva中在effects中获取state的值
自動控制(韓敏版)
sklearn之 Gaussian Processes
线代第四章-向量组的线性相关
EditorConfig
数字图像处理基础(冈萨雷斯)二:灰度变换与空间滤波
Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
在Jupyter notebook中用matplotlib.pyplot出现服务器挂掉、崩溃的问题
線性代數第一章-行列式
编写一个自己的 RedisTemplate
Delete and truncate
Pytorch学习记录(三):神经网络的结构+使用Sequential、Module定义模型
治療TensorFlow後遺症——簡單例子記錄torch.utils.data.dataset.Dataset重寫時的圖片維度問題
Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images
Exception handling: grab and throw model
Framework analysis 1 Introduction to system architecture
Solution record of slow access speed of SMB service in redhat6
The problem that the page will refresh automatically after clicking the submit button on the form is solved
Ptorch learning record (XIII): recurrent neural network