Skip to content

Commit 79c3a64

Browse files
committed
1 parent c36e53e commit 79c3a64

File tree

8 files changed

+1012
-4
lines changed

8 files changed

+1012
-4
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.jiangcoder.code;
2+
//package com.jiangcoder.code;
3+
//
4+
//import java.util.Set;
5+
//
6+
//public class RedisUtil {
7+
// public static void main(String[] args) {
8+
//
9+
// String ips = "10.58.22.12:7000,10.58.50.24:7000,10.58.51.86:7000,10.58.22.12:7001,10.58.50.24:7001,10.58.51.86:7001";
10+
// String[] ipPorts = ips.split(",");//
11+
// Set<HostAndPort> nodes = new HashSet<HostAndPort>();
12+
// for (String item : ipPorts) {
13+
// String[] addrItem = item.split(":");
14+
// nodes.add(new HostAndPort(addrItem[0], Integer.parseInt(addrItem[1])));
15+
// }
16+
//
17+
// JedisPoolConfig conf = new JedisPoolConfig();
18+
// conf.setMaxWaitMillis(10000);
19+
// conf.setMaxIdle(60000);
20+
// conf.setMaxTotal(6000);
21+
//
22+
// JedisCluster jedis = new JedisCluster(nodes, 5000, conf);
23+
//
24+
// String redisKeyField[] = splitKey(StringUtil.append("d", "@", "A0005478769"));
25+
// boolean isUncompress = true;
26+
// byte[] valueb = jedis.hget(redisKeyField[0].getBytes(), redisKeyField[1].getBytes());
27+
// // System.out.println(StringUtil.toString(StringUtil.uncompress(valueb)));
28+
// String newValue = valueb != null ? StringUtil.toString((true ? StringUtil.uncompress(valueb) : valueb)) : null;
29+
// System.out.println(JSON.parse(newValue));
30+
//
31+
// // String value = jedis.get("category" + "@" + "cat18596268");
32+
// // System.out.println(value);
33+
// try {
34+
// jedis.close();
35+
// } catch (IOException e) {
36+
// e.printStackTrace();
37+
// }
38+
// }
39+
//}
40+
//

src/main/java/com/jiangcoder/code/ReverseString.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,46 @@ public class ReverseString {
1313
* @param args
1414
*/
1515
public static void main(String[] args) {
16-
System.out.println(Reverse("woaini",2));
16+
System.out.println(ReverseJuly("woaini",3));
1717
}
18+
/**
19+
* author jiangtao
20+
* @param s
21+
* @param n
22+
* @return
23+
*/
1824
public static String Reverse(String s,int n){
1925
char[]temp=s.toCharArray();
20-
for(int i=0;i<temp.length;i++){
26+
String result = s.substring(n, s.length());
27+
System.out.println(result);
28+
if(s.length()>=n){
29+
for(int i=0;i<n;i++){
30+
result=result+temp[i];
31+
}
2132
}
22-
return s;
33+
34+
return result;
35+
}
36+
/**
37+
* 暴力移位法
38+
* @param s
39+
* @param n
40+
* @return
41+
*/
42+
public static String ReverseJuly(String s,int n){
43+
char[]temp=s.toCharArray();
44+
while (n-->0) {
45+
char first=temp[0];
46+
for(int i=1;i<s.length();i++){
47+
temp[i-1]=temp[i];
48+
}
49+
temp[s.length()-1]=first;
50+
}
51+
52+
String result="";
53+
for(int i=0;i< temp.length;i++){
54+
result=result+temp[i];
55+
}
56+
return result;
2357
}
2458
}

0 commit comments

Comments
 (0)