A string is a palindrome if it has exactly the same sequence of characters when traversed left-to-right as right-to-left. For example, the following s...
分类:
其他好文 时间:
2015-01-04 06:23:36
阅读次数:
230
按要求分解字符串,输入两个数M,N,M代表输入的M个待处理的字符串,N代表输出的每串字符串要处理成的位数,不够补0。
例如:
输入:2 8
abc 123456789
输出:abc00000
12345678,90000000
#include
#include
using namespace std;
string s;...
分类:
其他好文 时间:
2015-01-04 01:19:40
阅读次数:
183
1 class Solution { 2 public: 3 string convert(string s, int nRows) { 4 string a=""; 5 int len=s.length(); 6 if(lennRows && r...
分类:
其他好文 时间:
2015-01-03 23:48:25
阅读次数:
309
如果对于两种不同类型的数值进行比较,可能会写出以下的代码:int compare(const string &v1, const string &v2) { if (v1 v2) { return 1; } return 0;}这两个函数除对数值比较类弄不一样外,函...
分类:
编程语言 时间:
2015-01-03 23:46:39
阅读次数:
188
Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substr...
分类:
其他好文 时间:
2015-01-03 22:20:40
阅读次数:
131
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*
二级指针的第二种内存模型
*/
//打印字符串数组
intprintArray(chararrayStr[10][30],intnum)
{
inti=0;
for(i=0;i<num;i++)
{
printf("%s\n",arrayStr[i]);
}
return0;
}
//排序
intsortAr..
分类:
其他好文 时间:
2015-01-03 21:11:26
阅读次数:
159
如下代码:publicclassExample027{
publicstaticvoidmain(String[]args){
inti=0;
while(-1<<32!=0){
i++;
}
System.out.println(i);
}
}结果说明:将上述程序放到eclipse中,在输出行会有提示“Unreachablecode”。也就是while循环是死循环无法退出。结果..
分类:
编程语言 时间:
2015-01-03 21:10:22
阅读次数:
208
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*
二级指针的第一种内存模型
*/
//打印字符串数组
intprintArray(char**arrayStr,intnum)
{
inti=0;
for(i=0;i<num;i++)
{
printf("%s\n",arrayStr[i]);
}
return0;
}
//排序
intsortArrayStr..
分类:
其他好文 时间:
2015-01-03 21:09:47
阅读次数:
142
假设有若干对象存于一个 vector 中:
class Widget;
vectorWidget> vw;
后来由于某些原因,从该容器中删除了若干对象(参考erase-remove idiom )。对于 vector 和 string 来讲, erase() 和 clear() 并不会改变容器的capacity,也就不会改变他们的内存占用。
swap() 本意是用来交换两个容器...
分类:
其他好文 时间:
2015-01-03 21:09:05
阅读次数:
209
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*
二级指针的第三种内存模型
*/
//打印字符串数组
intprintArray(char**arrayStr,intnum)
{
inti=0;
for(i=0;i<num;i++)
{
printf("%s\n",arrayStr[i]);
}
return0;
}
//排序
intsortArrayStr..
分类:
其他好文 时间:
2015-01-03 21:08:41
阅读次数:
137