比如我想将 “javascript”反转为 “tpircsavaj”。我们一般处理都是用for循环然后用StringBuffer一个字符一个字符添加。
其实StringBuffer提供了一个reverse方法就可以实现。测试代码如下:
package com.evan;
public class ReverseTest {
public static void main(String[]...
分类:
编程语言 时间:
2014-07-16 17:19:54
阅读次数:
202
//将字符串反转,但单词不倒置。Right here waiting for you! -> you! for waiting here Right#define _CRT_SECURE_NO_WARNINGS#include #include int main() { char str[25...
分类:
其他好文 时间:
2014-07-14 19:42:46
阅读次数:
278
//将字符串反转,但单词不倒置。#include#includevoid reverse(char *s){ char data[255][255];//将s中的空格和非空格子串进行存储 int row = 0,column = 0; int i,j,k; for(i=0;s[i];) { data...
分类:
其他好文 时间:
2014-07-13 09:31:51
阅读次数:
202
Best Cow LineTime Limit:1000MSMemory Limit:65536KTotal Submissions:9284Accepted:2826DescriptionFJ is about to take hisN(1 ≤N≤ 2,000) cows to the annua...
分类:
其他好文 时间:
2014-07-09 14:20:50
阅读次数:
2624
很简单,逆向输出就好了。
import java.util.Scanner;
public class convertString {
public static void main(String args[]){
Scanner input=new Scanner(System.in);
String s=input.nextLine();
StringBuffer l=new Str...
分类:
其他好文 时间:
2014-07-09 09:11:55
阅读次数:
236
-(IBAction)abc:(id)sender{ NSString *a = @"abcdef"; NSMutableString *newA = [[NSMutableString alloc]init]; int length = a.length; for (int i = 0; ...
分类:
其他好文 时间:
2014-07-06 23:22:46
阅读次数:
210
其实编程之美也有类似的题,这道题是编程珠玑第二章的题目。题目描述:给定一个字符串,将字符串循环移位K次。最简答的方法就是,通过O(n)的辅助空间,将数组循环移位,时间复杂度就是O(n)但是如果要求空间复杂度为O(1)呢?观察规律可知,对前K位反转以及后面的反转,最后对整个字符串反转就能达到O(1)的...
分类:
其他好文 时间:
2014-06-10 21:02:52
阅读次数:
275
题目如下:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
click to show clarification.
Clarification:
What co...
分类:
其他好文 时间:
2014-06-08 14:58:13
阅读次数:
231
在ios7以前,我们开发二维码扫描,或者生产都需要借助第三方的开源库进行开发。
然后升级到ios7时,在passbook中苹果自带二维码扫描功能,而且扫描速度非常快,秒杀一切第三方开源库。所以,我们做二维码的开发选用自带sdk优先级应该高于其他的库。
说到二维码的开发,我们需要用到这两个对象。如下。。
@property (nonatomic,
strong) AVCaptureS...
分类:
移动开发 时间:
2014-06-08 09:04:05
阅读次数:
232