当前位置:网站首页>OR62 倒置字符串
OR62 倒置字符串
2022-07-29 21:49:00 【syc596】
OR62 倒置字符串
import java.util.*;
public class Main {
public static void reverse(char[] ch,int left,int right){
while(left<right){
char tmp=ch[left];
ch[left]=ch[right];
ch[right]=tmp;
left++;
right--;
}
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
String str=sc.nextLine();
char ch[]=str.toCharArray();
reverse(ch,0,ch.length-1);
int i=0;
while(i<ch.length){
int j=i;
while(j<ch.length&&ch[j]!=' '){
j++;
}
reverse(ch,i,j-1);
if(j<ch.length){
i=j+1;
}else{
i=j;
}
}
String ret=new String(ch);
System.out.println(ret);
}
}
}边栏推荐
- 高性能数据访问中间件 OBProxy(三):问题排查和服务运维
- The implementation of the flood control project and safety construction project in the flood storage and detention areas in Luluze and Ningjinbo was launched
- 三、HikariCP源码分析之获取连接流程三
- SQL教程之性能不仅仅是查询
- 专利说明书怎么写?
- Verilog 加法器设计
- 03-树3 Tree Traversals Again(树的遍历)
- linkedlist的用处之一:通过结构体成员的地址获取结构体变量的地址
- GBASE 8s 如何估算索引使用多少空间
- SAP Gui 730 安装的问题
猜你喜欢
随机推荐
How to implement your personal knowledge base?
ict的终极模式 是软件研发
GBASE 8s 自动删除正在被使用的数据库
jsonArray中按某字段排序
lambda表达式
转:idea中language level设置
COPU陆首群教授应邀在ApacheCon Asia会议上致辞
[BUG]memset和成员初始化的先后顺序
官宣!苏州吴江开发区上线电子劳动合同平台
【CVPR2022】A Unified Query-based Paradigm for Point Cloud Understanding
一、HikariCP源码分析之获取连接流程一
爽朗的一天
leetcode122. Best Time to Buy and Sell Stock II
JZ24 反转链表
C. Color the Picture(贪心/构造)
CNCF Keith Chan:分布式云时代,云原生社区的发展与趋势
[HDLBits brush questions] Verilog Language (4) Procedures and More Verilog Features section
高等数学(第七版)同济大学 习题3-7 个人解答
华为畅享50 Pro评测:HarmonyOS加持 更流畅更安全
【CVPR2022】A Unified Query-based Paradigm for Point Cloud Understanding









