Java classic algorithm_011 has 1, 2, 3, and 4 numbers. How many different three-digit numbers can be formed without repeated numbers? How many are they?
Question: There are 1, 2, 3, and 4 numbers. How many different three-digit numbers can be formed without repeated numbers? How many are they? package com.arithmetic;/** * Question: There are 1, 2, 3, and 4 numbers. How many different numbers can be formed? The same three-digit number without repeating digits? How many are they? * * @author Administrator * */public class Test_wzs11 {public static void main(String[] args) {int temp = 0;for (int i = 1; i <= 4; i++) {for (int j = 1; j <= 4; j++) {for (int k = 1; k <= 4; k++) {if (i != j && j != k && i != k) {temp = i * 100 + j * 10 + k;System.out.print(temp + “,”);}}}}}}
PHP array, how does $a={0,1,2,3} become $a={1,2,3,4]
PHP array, how does $a = {0,1,2,3} become $a = {1,2,3,4]PHP array, how does $a = {0,1,2,3} change becomes $a = {1,2,3,4]. It is the dimension of the multi-dimensional array, and then adds 1 to the dimension and outputs it as the sequence number of the table, 1, 2, 3, 4——Solution—- —————- $a = array(0, 1, 2, 3); $b = range(1, count($a)); $c = array_combine($b, $a); print_r($c); Array ( [1] => 0 [2] => 1 [3] => 2 [4] => 3 ) ——Solution——————– $arr = array(0,1,2,3); $temp = array(); foreach($arr as $k=>$v){ $k++; $temp[] = $k; } print_r($temp); The moderator’s is prettier! ——Solution—— —————The moderator’s idea is beautiful, and here is another idea. <?php $a = array(0,1,2,3); array_unshift($a, 0); // Insert a new element at the beginning of the array to increase the key by 1 unset($a[0]); // Delete the newly added elements at the beginning, but the key remains unchanged print_r($a); // Output ?>
PHP array, how does $a={0,1,2,3} become $a={1,2,3,4]
PHP array, how does $a = {0,1,2,3} become $a = {1,2,3,4]. It is the dimension of the multi-dimensional array, and then adds 1 to the dimension and outputs it as the sequence number of the table, 1, 2, 3, 4 Reply to the discussion (solution) $a = array(0, 1, 2, 3);$b = range(1, count($a ));$c = array_combine($b, $a);print_r($c); Array ( [1] => 0 [2] => 1 [3] => 2 [4] => 3 ) $arr = array(0,1,2,3);$temp = array();foreach($arr as $k=>$v){ $k++; $temp[] = $k; }print_r($temp); The moderator’s is more beautiful! The moderator’s idea is beautiful, here is another idea.
php Sheep die once every 5 years. It is known that a sheep has a lifespan of 7 years and gives birth to a lamb when it is 2, 3, or 5 years old (regardless of male or female,…
The suspected violation of this floor has been collapsed by the system. Hide this floor and view this floor public class Sheep{ Boolean isAlive=true; Integer year=1; public void nextYear(List sheeps){ year++; if((year= ;=2 || year==3 || year==5)&&isAlive) sheeps.add(new Sheep()); else if(year>=7) isAlive=false; } int afterNYearSheepNum(int n, List sheeps){ for(int i=0;i List tmpSheeps=newArrayList(); sheeps.stream. foreach((sheep)->{ sheep.nextYear(tmpSheeps); }) sheeps.addAll(tmpSheeps); p>} sheeps.removeIf((sheep)->!sheep.isAlive); return sheeps.size(); } public static void main(String [] arg){ List sheeps=new ArrayList(); sheeps.add(new Sheep()) ; int num=afterNYearSheepNum(10,sheeps) } }
underscore knowledge points_error: partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,_cily_undefined’s blog
1. Installation Node. js –> npm install underscore Meteor.js –> meteor add underscore Require.js –> require([“underscore”], … Bower bower –> install underscore Component –> component install jashkenas/underscore Second, aggregate function (array or object) 1, each Syntax: _.each(list, iteratee, [context]) Description: Traverse all elements in the list, and call the iteratee function with each element as a parameter in order. If the context parameter is passed, bind iteratee to the context object. Each call to iteratee passes three parameters: (element, index, list). If list is a JavaScript object, the arguments to iteratee are (value, key, list)). Return a list to facilitate chain calls. Example: _.each([1, 2, 3], alert); => alerts each number in turn… _.each({one: 1, two: 2, three: 3}, alert); => alerts each number value in turn… 2, map Syntax: _.map(list, iteratee, [context]) Description: Generate a corresponding array by calling the conversion function (iteratee iterator) for each element in the list. iteratee passes three parameters: value, then the iteration index (or key Fool’s Wharf note: if the list is a JavaScript object, this parameter is the key), and the last one is a reference to the entire list. Example: _.map([1, 2, 3], function(num){ return num * 3; }); => [3,…
count(1), count(*), orderby1,2,3,4 difference
Count(1), count(*), order by 1,2,3,4 difference the 1 make NULL data; the the 2 directly use the column name to COUNT to see the result the the 3 Use 1 2 3 4 5 * to COUNT to look at the results and find that they are all the same data and are equal to all functions. www.2cto.com the 4 ORDER BY 1 does use the first column to sort the the 5 ORDER BY 2 See if the result is correct the the result: the count(1)=count(2)=count(3)=count(*); the count(provcode)count(areacode)count(statedate)count(*); the order by 1order by 2oreder by 3; the order by 1=order by provcode the Additional results: the the the Author ZengMuAnSha