亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? permutations1.txt

?? 離散數學運用的小例子,很實在,很好很好用的啊
?? TXT
字號:


//=================================================================
// Name: class Permutations
// Author: Mike sun
// date:   05/05/2004
// a) This function implements dictionary-permutation algorithm
//    of the whole permutation of n numbers, 1,2 3,...,n
//
// b) parameters: a is any permutation of 1,2,...,n
// c) output: output all the permutations of 1,2,...,n
// d) The algorithm
//    for a given permutation a
//    1. find the maximun i such that a(i-1) < a(i), ie. find i=max(k: a(i-1) < a(i))
//    2. for the fixed i, find the maximum j such that a(i-1) < a(j), find j=max(k: a(i-1) < a(k))
//    3. swap a(i-1) with a(j), got new a(1),...,a(n)
//    4. in a(1),...,a(i-1), a(i),...,a(n), reverse a(i),...,a(n), got new a(1),...,a(n)
//    5. one loop of the steps 1,2,3,4 above will find the next permutation of the given a
//    6. all together there are n! permutations, and so use n! as the upper bound of the control loop
//
//
//=================================================================

import java.lang.Math;




 public class Permutations
 {
   private int permutations[][];
   private boolean isDecreasing=true;

   public Permutations()
   {}

   public int[][] findAllLexPermutations(int[] a)
   {
      int n=a.length;
      int k=1;
      int i=0;
      int j=1;

      int numPermutations = factorial(n);

      permutations=new int[numPermutations][n];

      //put the original line into the first line
      for (int q=0;q<n;q++)
      {
		  permutations[0][q]=a[q];
	  }

	  //----------------------------------------------
	  //test if the input a is monotonously decreasing
	  //then the boolean variable isDecreasing will be
	  //assigned value. If isDecreasing = true, then a[]
	  //is decreasing
	  //----------------------------------------------

	  testDecrease(a);

	  //-----------------------------------------------
	  // if the input a is decreasing, like 5 4 3 2 1
	  // then reverse it to 1 2 3 4 5 and load it into
	  // permutations[][]
	  //-----------------------------------------------
	  if ( isDecreasing == true )
	  {
	      a=reverse(a);
	      for (int q=0;q<n;q++)
		  {
		  	 permutations[1][q]=a[q];
	      }

	  }

      //-------------------------------------------------------
      // if a is not a decreasing array, then we start with p=1
      //-------------------------------------------------------
      if ( isDecreasing == false )
      {
      		for (int p=1;p<numPermutations; p++)
      		{
      			//--------------------------------------------------------------
      			// find the maximun i such that a(i-1) < a(i), ie. find
      			// i=max(k: a(k-1) < a(k)), i=1 if no k to satisfy a(k-1) < a(k),
      			//--------------------------------------------------------------
            	i=findMaxConsecutiveIncreaseIndex(a);

      			//--------------------------------------------------------------
     			// for the fixed i, find the maximum j such that a(i-1) < a(j),
     			// find j=max(k: a(i-1) < a(k)), if no such j, let j=1
      			//--------------------------------------------------------------
      			j=findMaxNonConsecutiveIndex(i, a);

      			//----------------------------------------------
     			// swap a(i-1) with a(j), got new a(1),...,a(n)
      			// if i=1, then don't swap
      			//----------------------------------------------
                a=swapTwoTerms(i, j, a);

      			//---------------------------------------------------------
      			// in a(1),...,a(i-1), a(i),...,a(n),reverse a(i),...,a(n),
      			// got new a(1),...,a(n) no reverse will happen if i=n
      			//---------------------------------------------------------
      			a=reverseRightHalf(i, a);

            	for (int y=0;y<n;y++)
            	{
            	    permutations[p][y]=a[y];
				}
     		}
      }
      else   // if a is a decreasing array, then we start with p=2
      {
      		for (int p=2;p<numPermutations; p++)
      		{
      			//--------------------------------------------------------------
				// find the maximun i such that a(i-1) < a(i), ie. find
				// i=max(k: a(k-1) < a(k)), i=1 if no k to satisfy a(k-1) < a(k),
      			//--------------------------------------------------------------
            	i=findMaxConsecutiveIncreaseIndex(a);


      			//--------------------------------------------------------------
				// for the fixed i, find the maximum j such that a(i-1) < a(j),
				// find j=max(k: a(i-1) < a(k)), if no such j, let j=1
				// 找使得a(i-1) < a(k)成立的最小的a(k)
      			//--------------------------------------------------------------
      			j=findMaxNonConsecutiveIndex(i, a);

      			//----------------------------------------------
     			// swap a(i-1) with a(j), got new a(1),...,a(n)
      			// if i=1, then don't swap
      			// 交換a(i-1) 和 a(j)
      			//----------------------------------------------
      			a=swapTwoTerms(i, j, a);

      			//---------------------------------------------------------
				// in a(1),...,a(i-1), a(i),...,a(n),reverse a(i),...,a(n),
				// got new a(1),...,a(n) no reverse will happen if i=n
				// 使得 a(i),...,a(n)反序
      			//---------------------------------------------------------
      			a=reverseRightHalf(i, a);

      			//將數組a的值賦給permutations
            	for (int y=0;y<n;y++)
            	{
            	    permutations[p][y]=a[y];
				}
     		}
      }
     return permutations;

 }

  public int factorial(int n)
  {
 	  int m=n;
 	  for (int k=n-1; k>0;k--)
 		   m=m*k;

 	  return m;
  }


  protected void testDecrease(int [] a)
  {
        for (int k=0;k<a.length-1;k++)
        {
  		    if (a[k] < a[k+1])
  		        isDecreasing = false;
	    }
  }


  protected int[] reverse(int[] a)
  {
	  int n=a.length;
	  int[] b= new int[n];

	  for (int k=0; k<n; k++)
	  {
		  b[k]=a[n-k-1];
	  }
	  return b;
   }


   protected int findMaxConsecutiveIncreaseIndex(int[] a )
   {
	     int count=0;
         for (int q=1;q<a.length;q++)      //yes
      	 {
        		if( a[q-1] < a[q] )      //%choose max i
            		count=q;
		 }
      	 return count; //%end choosing max i
   }


   protected int findMaxNonConsecutiveIndex(int i, int[] a)
   {
	    int count1=0;
		for (int m=1; m<a.length; m++)
      	{
        	if ( (i>0) && (a[i-1] < a[m])  )      //%choose max i
                	count1=m;
		}
		return count1;
   }

   protected int[] swapTwoTerms(int i, int j, int[] a)
   {
            if(i>0)
      		{
            		int q = a[i-1];
            		a[i-1] = a[j];
            		a[j] = q;
			}
	        return a;

   }

   protected int[] reverseRightHalf(int i, int[] a)
   {
	     int n=a.length;
         int b[];
      	 b=new int [n];


      	for (int m=i; m<n; m++)
      	     b[m]=a[n-m+i-1];

      	for (int m=i; m<n; m++)
      		a[m]=b[m];

	    return a;
   }




}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久先锋影音av鲁色资源网| 成人一二三区视频| 精品人在线二区三区| 另类综合日韩欧美亚洲| 久久噜噜亚洲综合| 91麻豆国产在线观看| 日本亚洲天堂网| 国产欧美日韩综合精品一区二区| 波多野结衣中文字幕一区| 亚洲国产精品一区二区www在线| 欧美日韩亚洲综合一区二区三区| 国产美女精品人人做人人爽| 久久蜜桃av一区二区天堂| 欧美在线观看你懂的| 国产成人精品一区二区三区网站观看| 亚洲欧美另类综合偷拍| 26uuu久久天堂性欧美| 欧美色图一区二区三区| 国产成人精品一区二区三区四区| 亚洲亚洲人成综合网络| 亚洲视频 欧洲视频| 久久久久久久久久看片| 欧美一区二区三区白人| 色婷婷久久一区二区三区麻豆| 成人午夜免费av| 丁香激情综合五月| 99re6这里只有精品视频在线观看| 老司机一区二区| 国产麻豆精品在线观看| 九色porny丨国产精品| 人妖欧美一区二区| 美脚の诱脚舐め脚责91| 精品一区二区国语对白| 国产一区二区三区| 国产在线不卡一区| 国产一区二区三区四区在线观看 | 亚洲美女偷拍久久| 亚洲欧美另类在线| 午夜av电影一区| 麻豆精品一二三| 国产91对白在线观看九色| 91在线高清观看| 欧美区视频在线观看| 91精品国产91久久久久久一区二区 | 成人做爰69片免费看网站| 91在线国产福利| 日韩午夜电影av| 亚洲欧洲一区二区三区| 麻豆精品在线观看| voyeur盗摄精品| 欧美一级欧美三级在线观看| 欧美精品一区二区在线观看| 国产精品人妖ts系列视频| 亚洲欧美偷拍另类a∨色屁股| 日韩在线一区二区三区| 国产成人啪免费观看软件| 欧美三级电影精品| 中文字幕日本不卡| 国产suv精品一区二区883| 欧美色男人天堂| 一区二区三区四区中文字幕| 国产精品综合二区| 精品久久人人做人人爱| 青青草91视频| 欧美日本在线观看| 亚洲一区二区三区视频在线播放 | av网站一区二区三区| 日韩欧美一区二区久久婷婷| 亚洲影院理伦片| 日本乱人伦aⅴ精品| 中文字幕一区二区三区四区 | 五月婷婷久久丁香| 欧美图区在线视频| 亚洲精品欧美二区三区中文字幕| 粉嫩绯色av一区二区在线观看| 国产日韩av一区二区| 国产精品自拍av| 国产三级精品在线| aaa亚洲精品| 色哟哟在线观看一区二区三区| 欧美成人一区二区三区在线观看 | 国产高清在线精品| 亚洲少妇中出一区| 欧美一区二区三区四区久久| 精彩视频一区二区| 亚洲人亚洲人成电影网站色| 在线观看精品一区| 久久精品国产99国产精品| 中文在线免费一区三区高中清不卡 | 亚洲欧美另类久久久精品2019| 欧美绝品在线观看成人午夜影视| 男女激情视频一区| 亚洲精品乱码久久久久| 国产婷婷色一区二区三区四区| 欧美中文字幕亚洲一区二区va在线| 免费成人在线视频观看| 亚洲愉拍自拍另类高清精品| 国产嫩草影院久久久久| 欧美一区二区在线播放| 欧美曰成人黄网| av电影天堂一区二区在线观看| 免费成人在线视频观看| 舔着乳尖日韩一区| 五月天一区二区| 亚洲国产一二三| 午夜久久久久久久久| 一区二区三区91| 一个色综合av| 亚洲综合色区另类av| 亚洲欧美中日韩| 亚洲综合视频网| 精品国产露脸精彩对白| 91麻豆精品国产91久久久久久久久| 91麻豆swag| 欧美日韩你懂得| 日韩欧美一二三区| 久久蜜桃一区二区| 国产精品久久久久国产精品日日| 国产无一区二区| 亚洲激情在线激情| 亚洲成人综合在线| 黄一区二区三区| 成人av网站在线观看| 欧美性色综合网| 精品少妇一区二区三区免费观看| 欧美高清在线视频| 亚洲制服丝袜在线| 激情图区综合网| 一本高清dvd不卡在线观看| 日韩一区二区三区视频| 国产精品久久久久久久久快鸭| 亚洲女人的天堂| 国产在线国偷精品产拍免费yy| 91麻豆国产福利精品| 欧美成人三级电影在线| 亚洲成人激情综合网| 成人午夜精品在线| 3d成人动漫网站| 亚洲精品老司机| 国产成人av影院| 日韩一区和二区| 亚洲国产一区二区视频| 9i看片成人免费高清| 国产亚洲午夜高清国产拍精品| 亚洲电影视频在线| 在线观看免费成人| 亚洲欧美日韩国产综合在线| 成人免费黄色大片| 久久综合色之久久综合| 久草这里只有精品视频| 日韩美女视频在线| 国内精品视频666| 国产日韩成人精品| 国产99精品国产| 国产精品国产三级国产专播品爱网| 国产在线看一区| 国产区在线观看成人精品| 夫妻av一区二区| 亚洲天堂a在线| 欧美三区在线观看| 美女www一区二区| 中文字幕欧美日韩一区| 91麻豆swag| 日本aⅴ精品一区二区三区| 丰满岳乱妇一区二区三区| 欧美一区二区三区公司| 亚洲精品成人悠悠色影视| 国产91富婆露脸刺激对白| 亚洲精品国产第一综合99久久 | 亚洲免费观看高清在线观看| 91久久一区二区| 国产一区二区中文字幕| 亚洲欧美福利一区二区| 欧美一区二区三区在线电影| 国产乱码精品一区二区三| 亚洲女人小视频在线观看| 欧美不卡在线视频| 国产一区二区美女| 午夜影院久久久| ...中文天堂在线一区| 日韩亚洲欧美高清| 欧美性欧美巨大黑白大战| 国产麻豆一精品一av一免费| 日韩精品亚洲一区| 一区二区三区视频在线观看 | 一区二区高清免费观看影视大全 | 狠狠狠色丁香婷婷综合久久五月| 亚洲欧美色一区| 国产精品黄色在线观看| 国产日本亚洲高清| 久久久国产一区二区三区四区小说| 欧美丝袜丝交足nylons图片| 成人性生交大合| 99久久久国产精品| 成人美女视频在线看| 国产精品亚洲综合一区在线观看| 麻豆精品新av中文字幕| 国产精品资源在线| 国产一区二区在线看| www.66久久|