Table of Contents
这样用01串,用01串
记录一个年龄段你会怎么记录,能表达类似“50~70”之类的就可以?
从1、2、3、......、199、200里面随机选些数,怎么表示?
Home php教程 php手册 这样用01串,用01串

这样用01串,用01串

Jun 13, 2016 am 09:07 AM
thing several point Discover and place use of

这样用01串,用01串

  今天在做东西的时候,发现了几个挺有意思的地方,记下来和大家分享分享。从几个小问题开始

记录一个年龄段你会怎么记录,能表达类似“50~70”之类的就可以?

  也许你会说很简单啊,用两个字段,一个start=>开始年龄、一个end=>结束年龄,更或者在一个字段中,使用start|end这样的格式,中间用一个非数字隔开,或者用start|start-end,哈哈,反正方法很多,但是这时候如果要求升级,要你表示10~20、25、29~40这些年龄,你要怎么表示呢?当然还可以通过字符串去表示比如:10-20|25|29-40,自己定一些规则去表示,但是这个表示方法还可以优化吗,答案是肯定的。

  可以用01字符串去表示不重复的年龄区间,默认是100个0,标志1~100岁的位置,如果为1则表示有该年龄,为零则表示没有该年龄。为了好说明,这里使用10个零,表示1~10岁,那么:

<p>0111111000    =>  表示2~7岁</p>
<p>0110111010    => 表示2~3、5~7、9岁</p>
Copy after login

  哈哈,是不是很方便就可以表示了,而且很容易理解,当然了,这样也有他的缺点,这样表示起来很方便,但是用起来确不方便,需要去计算。

从1、2、3、......、199、200里面随机选些数,怎么表示?

  当然了,这个方法有很多种,比如说用字符串表示,每个数字之间用非数字分割,像这样:1|5|100|199。我想说的这种还是用01串表示,就像上面的1~200,选取其中的一部分这个问题,我可以使用200个位置的字符串,每个位置是0或者1,每个位置放好是它对应的数字,这样的话,就又将这些信息表示为01字符串了。还是按照0~10举个例子

<p>0111111000    =>  表示2、3、4、5、6、7</p>
<p>0110111010    => 表示2、3、5、6、7、9</p>
Copy after login

  当然了有人可能会说了,我想表示的数据不是连续的,比如说我想表示

  1926、19658、12、5638、8975、965、369、5126、5698、14556

  上面这些数有的很大有的很小,没有规律,我们要表示总体不超过10个的数不会去用他们中最大的个数个位置吧(比如说这里19658个0),当然不会,这种情况可以使用映射,映射关系如下:

<span>1</span> => <span>1926</span><span>,
</span><span>2</span> => <span>19658</span><span>,
</span><span>3</span> => <span>12</span><span>,
</span><span>4</span> => <span>5638</span><span>,
</span><span>5</span> => <span>8975</span><span>,
</span><span>6</span> => <span>965</span><span>,
</span><span>7</span> => <span>369</span><span>,
</span><span>8</span> => <span>5126</span><span>,
</span><span>9</span> => <span>5698</span><span>,
</span><span>10</span> => <span>14556</span>
Copy after login

  这个时候要想表示1926、12、5698这几个选中的情况的时候,可以使用下面的01串:

  1010000010

  也许你也发现了,这个还可以起到节省流量的效果,我们在双方交互的时候,把映射关系建立好,网络传递的时候不需要传递真实的数据,只需要传递对应的01串就行。

  当然了,这个还可以表示很多东西,比如说我把一天的时间没5分钟分为1段,一共有288段,这个时候从这里面随机选取一些个5分钟段,用288个自己长度的01串来表示这个是不是挺好的,哈哈。

  在某种情况下这种01串表示的方式还是挺可取的,有时候会起到节省流量的效果。

 

  本文版权归作者iforever(luluyrt@163.com)所有,未经作者本人同意禁止任何形式的转载,转载文章之后必须在文章页面明显位置给出作者和原文连接。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed introduction to what wapi is Detailed introduction to what wapi is Jan 07, 2024 pm 09:14 PM

Users may have seen the term wapi when using the Internet, but for some people they definitely don’t know what wapi is. The following is a detailed introduction to help those who don’t know to understand. What is wapi: Answer: wapi is the infrastructure for wireless LAN authentication and confidentiality. This is like functions such as infrared and Bluetooth, which are generally covered near places such as office buildings. Basically they are owned by a small department, so the scope of this function is only a few kilometers. Related introduction to wapi: 1. Wapi is a transmission protocol in wireless LAN. 2. This technology can avoid the problems of narrow-band communication and enable better communication. 3. Only one code is needed to transmit the signal

How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) Dec 31, 2023 pm 05:15 PM

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

The first choice for CS players: recommended computer configuration The first choice for CS players: recommended computer configuration Jan 02, 2024 pm 04:26 PM

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

Digital audio output interface on the motherboard-SPDIF OUT Digital audio output interface on the motherboard-SPDIF OUT Jan 14, 2024 pm 04:42 PM

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Jan 01, 2024 pm 12:52 PM

Glodon Software is a software company focusing on the field of building informatization. Its products are widely used in all aspects of architectural design, construction, and operation. Due to the complex functions and large data volume of Glodon software, it requires high computer configuration. This article will elaborate on the computer configuration recommendations of Glodon Software from many aspects to help readers choose a suitable computer configuration processor. Glodon Software requires a large amount of data calculation and processing when performing architectural design, simulation and other operations. Therefore, the requirements for the processor are higher. It is recommended to choose a multi-core, high-frequency processor, such as Intel i7 series or AMD Ryzen series. These processors have strong computing power and multi-thread processing capabilities, and can better meet the needs of Glodon software. Memory Memory is affecting computing

ASUS motherboard options compatible with R55600 (including R55600u and 5600h) ASUS motherboard options compatible with R55600 (including R55600u and 5600h) Jan 02, 2024 pm 05:32 PM

Which ASUS motherboard should be paired with the R55600? The ASUS ROGStrixB550-FGaming motherboard is an excellent choice. It is perfectly compatible with Ryzen55600X processor and provides excellent performance and features. This motherboard has a reliable power supply system, can support overclocking, and provides a wealth of expansion slots and ports to meet daily use and gaming needs. ROGStrixB550-FGaming is also equipped with high-quality audio solutions, fast network connections and reliable heat dissipation design to ensure that the system remains efficient and stable. In addition, this motherboard adopts a gorgeous ROG style and is equipped with gorgeous RGB lighting effects, adding visual enjoyment to your computer. All in all, ASUS ROGStri

Which one is better, Celeron g4900 or i36100? (Which one is better, Celeron g4900 or i34170?) Which one is better, Celeron g4900 or i36100? (Which one is better, Celeron g4900 or i34170?) Jan 01, 2024 pm 06:01 PM

Which one is better, Celeron g4900 or i36100? When it comes to the two processors Celeron G4900 and I36100, there is no doubt that the performance of I36100 is superior. Celeron processors are generally considered low-end processors and are primarily used in budget laptops. The I3 processor is mainly used for high-end processors, and its performance is very good. Whether you are playing games or watching videos, you will not experience any lagging when using the I3 processor. Therefore, if possible, try to buy Intel I-series processors, especially for desktop computers, so that you can enjoy the fun of the online world. How is the performance of the Celeron G4900T? From a performance perspective, the Pentium G4900T performs well in terms of frequency. Compared with the previous version, the CPU performance is

Please recommend a cost-effective 1155-pin CPU Please recommend a cost-effective 1155-pin CPU Jan 14, 2024 pm 01:30 PM

Please recommend which 1155-pin CPU is the best. The current 1155-pin CPU with the highest performance is Intel Corei7-3770K. It has 4 cores and 8 threads, a base frequency of 3.5GHz, and supports TurboBoost2.0 technology, which can reach up to 3.9GHz. In addition, it is equipped with 8MB of level 3 cache and is an excellent processor with the LGA1155 pin, the most powerful CPU Intel Core i73770K. The LGA1155 interface is the interface type used by second and third generation Core processors. The best performing one is Intel Core i73770K. The parameters of this processor are as follows: 1. Applicable type: desktop; 2. CPU series: Core i7; 3. CPU

See all articles