题目一:求1!+2!+…..+n! 的和的后6位,(注意n的范围)
#include <iostream>
using namespace std;
const int MAX = 1000000;
int getResu(int n)
{
	int sum=0;
	int temp= 1;
	for(int i=1; i <= n; i++)
	{
		temp *= i;
		temp %= MAX;
		sum += temp;
		sum %= MAX;
	}	
	return sum ;	
}
int main()
{
	int n;
	while(cin>>n)
	{
		if(n > 0)
			cout << getResu(n) << endl;
		else
			cout << "Please input a integer greater than zero !" <<endl;
	}
	return 0;
}#include <iostream>
#include <cstdlib>
// 设置随机函数
#include <ctime>
using namespace std;
const int MAX_COUNT = 10000;
const int MAX_VALUE = 1000;
int number[MAX_COUNT];
void init()
{
  //0-1000
	for(int i=1; i <= MAX_COUNT; i++)
		number[i] = rand()%MAX_VALUE;
	for(int i=1; i <= MAX_COUNT; i++)
		cout << number[i] << " ";
	cout << endl;
}
void solve()
{
	int max, min, flag;
	if((flag=MAX_COUNT%2))// 如果为真,1
		max=min=number[1];
	else{// 为偶数的情况
		if(number[1]>number[2])
		{
			max = number[1];
			min = number[2];
		}else{
			max = number[2];
			min = number[1];
		}
	}
	if(flag) flag = 2;
	else flag = 3;
	for(int i=flag; i < MAX_COUNT; i+=2)
	{
		if(number[i]>number[i+1])
		{
			if(number[i] > max)
				max = number[i];
			if(number[i+1] < min)
				min = number[i+1];		
		}else{
			if(number[i+1] > max)
				max = number[i+1];
			if(number[i] < min)
				min = number[i];
		}
	}
	cout << "MAX = " << max << endl;
	cout << "MIN = " << min << endl;
}
int main()
{
  //随机函数的种子
	srand(time(NULL));
	init();// 初始化
	solve();// 解决
	return 0;
}
题目三:排列问题
参考我的另一篇博客:http://blog.csdn.net/china_zoujinyong/article/details/17588897
题目四:台阶问题
问题描述:我们学校北区食堂一楼到二楼的楼梯一共有17个台阶,正常人的你一次可以选择迈1个台阶,2个台阶,或3个台阶,问你从最底下走上17个台阶,一共有多少种走法?
解法一:
上n个台阶的方法等于上n-1个台阶和n-2个台阶和n-3个台阶的方法之和
台阶数 方法 步骤
1 1
2 2 1+1
4 3 1+2 1+1+1 2+1
7 1+3 1+2+1 1+1+1+1 1+1+2 2+1+1 2+2 3+1
13 1+1+1+1+1 1+2+2 2 +1+2 1+2+1 1+1+3 3+1+1 1+3+1
1+2+1+1 1+1+2+1 2+1+1+1 1+1+1+2 2+3 3+2
6 24 1+1+1+1+1+1 2+1+1+1+1 (5种) 3+1+1+1 (4种)
2+2+1+1(6种)2+3+1 (6种) 3+3 2+2+2
#include <iostream>
using namespace std;
int recu(int n)
{
  if(n==1) return 1;
  if(n==2) return 2;
  if(n==3) return 4;
  return recu(n-1)+recu(n-2)+recu(n-3);
}
int main()
{
  int n;
  cin >> n;
  cout << recu(n) << endl;
  return 0;
}
#include <iostream>
using namespace std;
int n, resu=0;
int number[3]={1,2,3};
void recu(int count)
{
  if(count==n)
    {
      resu++;
      return ;
    }
  if(count > n)
    return ;
  for(int i=0; i < 3; i++)
    {
      count += number[i];
      recu(count);
      count -= number[i];
    }
}
int main()
{
  cin >> n;
  recu(0);
  cout << resu << endl;
  return 0;
}原文地址:http://blog.csdn.net/china_zoujinyong/article/details/25950571