public int qiuyang(int cun) { int sum = 0; if (cun==7)//如果是第七个村就剩2只,那么函数结束 { sum = 2; return sum; } sum = (qiuyang(cun + 1) + 1) * 2; //(下一个村数量+1)*2; ...
分类:
其他好文 时间:
2015-04-15 16:28:49
阅读次数:
127
对折纸的例题: double houdu = 0.001; for (int i = 1; 1==1; i++) { houdu = houdu + houdu; Console.WriteLine("第"+i+"次对折后纸的厚度为"+houdu+"米" ); if (houdu >=8848) {...
分类:
其他好文 时间:
2015-04-15 16:26:48
阅读次数:
277
#include#include#include#include #include#include /*孤儿进程int main(void){ pid_t pid; pid = fork(); if (-1 == pid) { perro...
分类:
系统相关 时间:
2015-04-15 16:25:16
阅读次数:
173
#include#include#include#includeusing namespace std;#define N 100001typedef long long ll;int v[NQ[i].t;--j) { if(vis[CH[j].x]) ...
分类:
其他好文 时间:
2015-04-15 16:23:48
阅读次数:
614
编写程序计算车速:一个人开车去旅行,某时刻发现里程表上显示98589.经过两个小时,第一次显示了下一个回文数。求里程以及速度。回文数:一个数的数字排列正反相同,例如98589,13431int main(){ int s1 = 98589; int s2 = s1; int a, ...
分类:
其他好文 时间:
2015-04-15 16:22:58
阅读次数:
147
public class Test {public static void main(String[] args) {String string="a b c d e f g";String Count[] = string.split(" "); //遇到空格就拆分。for(int i=0;i<C...
分类:
编程语言 时间:
2015-04-15 16:19:26
阅读次数:
149
#include#include#include#include #includevoid LoopFunc(int);int main(void){ int procNum = 0; int loopNum = 0; int i, j; pid_t pid; ...
分类:
其他好文 时间:
2015-04-15 16:16:28
阅读次数:
127
刚开始求height数组的地方写错了,看来还是理解不够透彻啊
所有的子串减去重复的子串
//先在草稿纸上把思想想清楚再动手,不要只是有个大概的思想,不然容易出错
#include
#include
#include
using namespace std;
#define N 10005
int n;
char s[N];
int r[N],sa[N],height[N],rank[N],...
分类:
其他好文 时间:
2015-04-15 14:56:59
阅读次数:
202
#include
using namespace std;
class Base
{
int x;
public:
Base(int a)
{
x = a;//记得给私有成员赋初值,没有的话会是随机值
cout<<"constructing Base "<<x<<endl;
}
~Base()
{
co...
分类:
编程语言 时间:
2015-04-15 14:56:27
阅读次数:
154
这两题都比较简单,第一题输出杨辉三角,第二题输出特定的某一行,第二题要求空间复杂度为O(k)
代码如下:
Pascal's Triangle:
public List> generate(int numRows) {//direct simulate
List> rs = new LinkedList>();
if(numRows == 0)retur...
分类:
其他好文 时间:
2015-04-15 14:55:55
阅读次数:
135