自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

程序人生

未曾清贫难成人,不经打击老天真。 自古英雄出炼狱,从来富贵入凡尘。 醉生梦死谁成器,拓马长枪定乾坤!

  • 博客(79)
  • 收藏
  • 关注

原创 排列的字典序问题

#include #include /*借鉴网上实现代码*/typedef long long int doubleLong; int f(int number) { if ( number == 1) return 1; return number*f(number - 1);}int main(){ doubleLong length, i, j; doubleLo

2016-12-24 14:39:00 628

原创 集合划分问题

#include int count(int n, int m) { if ((m > n ) || (m == 0)) return 0; if ((m == 1 ) || (m == n)) return 1; return count(n-1, m-1) + m*count(n-1, m); //根据公式求解}int main() { int result = 0;

2016-12-24 14:37:01 599

原创 标准二维表问题

#include /* *思路: 这是一个卡特兰数列 * f(1) = 1, f(2) = 1, f(0) = 1; * f(n) = f(0)*f(n-1) + f(1)*f(n-2) + .... + f(n-1)*f(0) * */int recursive(int number) { int result = 0; if (number == 1 || number =

2016-12-24 14:35:24 1168

原创 整数因子分解法

import java.util.Scanner;/** * * @author x_zhaohu */public class NumberSplit { static int count = 0; /** * @param args the command line arguments */ public static void main

2016-12-24 14:33:53 689

原创 矩阵连乘 备忘录

public class MatrixNote { int matrixNote(int[] p, int i, int j, int[][] s,int[][] m) { int k, minValue, tempValue; if(m[i][j]>0) return m[i][j]; if(i == j) { minValue=0; } else {

2016-12-24 14:32:16 638

原创 动态-矩阵连乘

public class MatrixFormDynamicProgramming { public static void matrixChain(int[] arrays, int[][] multiplicationTimes, int[][] result) { for(int i = 1; i < arrays.length; i++) { multiplicationTi

2016-12-24 14:30:39 257

原创 矩阵连乘问题

public class MatrixRecursion { //参照老师上课写的程序. public int minCount(int[] arrays, int i, int j, int[][] s){ int minValue=100000; if(i==j) return 0; for(int k = i; k < j; k++) { int tempVa

2016-12-24 14:27:46 518

原创 独立任务调度问题

#include #define n 6int a[n] = {2, 5, 7, 10, 5, 2};int b[n] = {3, 8, 4, 11, 3, 4}; int main() { int sumA=0; int result=1000000; for(int i = 0; i < n; i++){ sumA += a[

2016-12-24 14:26:04 807

原创 石子合并问题

#include #define k 4int data[k] = {4, 4, 5, 9};void sort(int data[]) { int i,j; for (i = 0; i < k; i++) { for (j = i+1; j < k; j++) { if (data[i] > data[j]) { int temp = data[i]; da

2016-12-24 14:24:12 297

原创 数字三角形

#include int main() { int data[101][101]; int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { scanf("%d", &data[i][j]); } } int max[101][101] = {0};

2016-12-24 14:21:51 230

原创 最优服务次序

import java.util.*;public class MinV { public static void main(String[] args) { int[] data= {52, 16, 1, 99, 1000, 234, 33, 55, 99, 812}; Arrays.sort(data); int sum = 0; for (int i = 0; i <

2016-12-24 14:17:21 396

原创 最小重量和问题

#include #define n 3int a[n];int minPrice = 1000000;int price;int priceArray[3][3] = {10, 2, 3, 2, 3, 4, 3, 4, 5};int ok(int t) { for (int i = 0; i < t; i++) { if (a[i] == a[t]) return

2016-12-24 14:13:43 324

原创 李白打酒

#include #include int a[14]; int count=0;//t 经过的次数 s 商场 f花  c酒 void backtrace(int t,int s,int f,int c){ if(s>5 || f>9 || c<=0 )//剪枝 return; if(t==14){ if(s=

2016-12-24 14:04:18 348

原创 N皇后

//#include //#include //#include //#define n 8//int judge(int *data) {// for (int i = 0; i < n; i++) {// for (int j = i+1; j < n; j++) {// if ((data[i] == data[j]) || (abs(i-j) == abs(data[i

2016-12-24 14:02:59 250

原创 批处理作业问题

#include //参照课本程序#define n 3 int M[n][2] = {2, 1,3, 1,2, 3}; // 各作业所需的处理时间int x[n]; //当前作业调度int bestX[n]; //当前最优作业调度int f2[n]; // 机器2完成处理时间int f1; //机器1完成处理时间int f; //完成时间和int bestF; //

2016-12-24 12:13:36 572

原创 符号三角形

#include #define n 7int sum;int count;int array[n+1][n+1]; int half;void traceback(int t) { if(t > n) sum++; if( (count > half) || ( t * (t-1) / 2 - count > half)) r

2016-12-23 16:52:05 419

原创 图的m着色问题

#include/*图的m着色问题*/#define n 5#define m 4int a[n][n] = {0, 1, 1, 1, 0,1, 0, 1, 1, 1,1, 1, 0, 1, 0,1, 1, 1, 0, 1,0, 1, 0, 1, 0};int x[n+1];int sum;int ok(int k){ for(int j=1;j<=n;j++)

2016-12-23 11:14:40 1533

原创 数字排列

#include int a[8];int isOk(int t) { for (int i = 1; i < t; i++) { if (a[i] == a[t] || a[t] == a[i]+i+1) return 0; } return 1;}void traceback(int t) { if (t == 8) { if (a[7] == 1 && a

2016-12-21 16:08:53 299

原创 数独问题

#include #define n 9int a[n][n] = {0, 0, 5, 3, 0, 0, 0, 0, 0,8, 0, 0, 0, 0, 0, 0, 2, 0,0, 7, 0, 0, 1, 0, 5, 0, 0,4, 0, 0, 0, 0, 5, 3, 0, 0,0, 1, 0, 0, 7, 0, 0, 0, 6,0, 0, 3, 2, 0, 0, 0, 8, 0,

2016-12-21 14:12:47 335

原创 连续邮资问题

#include #define n 6#define m 4int money;int flag;int post[n] = {0, 1, 3, 11, 15, 32};int num;void traceback(int t) { if (flag) return ; if (t == m) { if (money == num) flag = 1;

2016-12-18 14:49:50 833

原创 39阶台阶

#include int step = 0; int count;void traceback(int foot) { if (foot%2 == 0 && step == 39) { count++; return; } step++; foot++; if (step < 39) { traceback(foot); } foot--; step--;

2016-12-17 23:10:57 474

原创 迷宫问题

#include #include #define n 5#define m 5/*地图*/char place[m][n] = {'.', '.', '.', '*', '*','*', '.', '*', '*', '.','.', '.', '.', '.', '.','.', '.', '.', '.', '.','*', '.', '.', '.', '.'};

2016-12-17 22:57:21 239

原创 工作分配问题

#include #define n 3int a[n];int minPrice = 1000000;int price;int priceArray[3][3] = {10, 2, 3, 2, 3, 4, 3, 4, 5};int ok(int t) { for (int i = 0; i < t; i++) { if (a[i] == a[t]) return

2016-12-16 10:19:50 442

原创 拉丁矩阵问题

#include #include #define m 3#define n 3int count=0;int a[m][n];int ok(int x, int y) { for (int i = 0; i < x; i++) { if (a[i][y] == a[x][y]) return 0; } return 1;}/*考虑边界条件, 当走到最后一个元

2016-12-16 09:52:58 1388

原创 数字三角形问题

#include int main() { int data[101][101]; int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { scanf("%d", &data[i][j]); } } int max[101][101] = {0};

2016-12-15 21:38:54 246

原创 租用游艇问题

#include #include int p[200][200];#define min(a, b) (a < b ? a:b ) int main() { int n; scanf("%d", &n); for (int i = 0; i < n-1; i++) { for (int j = i+1; j<n; j++) { scanf("%d", &p[i][

2016-12-15 21:07:29 396

原创 最小m序列和

#include#include#define INF 1e9#define MAX 1001#define max(a, b) ((a)>(b) ? (a):(b))int data[MAX], tempData[MAX][MAX];int minMOrder(int n, int m){ int i, j, k; memset(tempData, 0, size

2016-12-15 20:31:21 610

原创 最大k乘积问题

package test;/*两个字:蛋疼! 参考网上的程序掉坑里啦,还好捋过来了*/import java.util.*;public class Util { public static void main(String[] args) { Scanner in = new Scanner(System.in); String data = null; int k = 0;

2016-12-15 19:45:10 474

原创 重复元素全排列

#include int data[4] = {1, 1, 2, 2};/*数据互换*/void swap(int data[], int index, int i) { int temp = data[index]; data[index] = data[i]; data[i] = temp;}/*是否已有*/int isEquals(int data[], int in

2016-12-11 10:07:00 265

原创 汽车加油问题

#include #include #include #define n 7#define k 7int data[k+1] = {1, 2, 3, 4, 5, 6, 7, 1};int detance[k];int result = 100000;int temp = 0;void dfs(int number, int contain) { if (number > k

2016-12-11 09:20:47 551

原创 最优合并问题

#include #define k 4int data[k] = {5, 12, 11, 2};void sort(int data[]) { int i,j; for (i = 0; i < k; i++) { for (j = i+1; j < k; j++) { if (data[i] > data[j]) { int temp = data[i];

2016-12-11 09:19:55 849

原创 会场安排问题

#include #define k 5int time[5][2] = {1, 35, 12, 28, 25, 35, 27, 80, 36, 50};/*思路:默认会场为k, 如果有活动A的开始时间 > 某活动B的结束时间, *如果是同一个会场,将一个会场A的结束的时间 = 会场B的结束时间, 会场B的时间全部赋成0,下次遍历通过>0里过滤掉 *这样两层循环下来就计算出了结果.

2016-12-11 09:18:54 268

原创 将两个正整数的最大公约数表示成两个数的线性组合, data1 * n + data2 *m = gcd(data1, data2)

#include int gcd(int data1, int data2) { if (data1 > data2 && data1 % data2 == 0) { return data2; } return gcd(data2, data1%data2);}int main(){ int num1,num2; int temp; scanf("%d%d",&num

2016-12-09 16:52:19 961

原创 最优分解问题(Java版)

import java.util.*;public class NiceDec { public static void main(String[] args) { Scanner in = new Scanner(System.in); int data = in.nextInt(); int sum = 0; ArrayList list = new ArrayLis

2016-11-25 17:44:14 430

原创 给定一个整数,并允许将其删除n个数字,使得值最小,例:data:178593, 删除一个数字,result:17593

import java.util.Scanner;import java.util.*;import java.util.Iterator;public class Smile { /* * 最近正好在复习数据结构,深入java常用集合. * 将其应用于实际 * 存在既有价值,各有优缺点,针对不同的环境应用合适的实现策略. * ArrayList优点:查询 * List

2016-11-25 16:59:56 498

原创 定义Car类,包含两个字段:name和price; (2)在Main方法中,使用Array.Sort方法对Car对象数组根据姓名和价格排序。

/*破ide 时好时不好,搞的我以为代码有问题,重建工程后,一切正常, 这是搞毛线,越来越厌恶cjing*/using System;using System.Collections;public class Car{ public string name; public double price; public Car(string name, double

2016-11-22 11:13:36 4173

原创 二维数组中的查找

/*题目描述在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。*/public class Solution { public boolean Find(int target, int [][] array) { for (int i = 0; i < arra

2016-11-14 21:56:52 220

原创 01背包---递归(16.11.04)

public class PackQuestion { private int[] w = {2, 2, 6, 5, 4}; private int[] v = {6, 3, 5, 4, 6}; public int result(int i, int j) { if (i == 4) { if (j >= w[i]) return v[i]; else

2016-11-04 21:31:00 275

原创 电路布线---动态规划(16.11.04)

public class CWDynamic { public static void main(String[] args) { CWDynamic cwd = new CWDynamic(); int[] arrays = {0, 8, 7, 4, 2, 5, 1, 9, 3, 10, 6}; int[][] s = new int[11][]; for (int i =

2016-11-04 20:58:29 736

原创 电路布线(16.11.04)

递归求解:public class CircuitWiring { private int[] arrays = {7, 6, 3, 1, 4, 0, 8, 2, 9, 5}; public int size(int i, int j) { if (i == 0) { if (j >= arrays[i]) return 1; else return 0;

2016-11-04 18:10:42 522

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除