Table of Contents
简单的PHP算法题(带扩充),php算法题扩充
Home php教程 php手册 简单的PHP算法题(带扩充),php算法题扩充

简单的PHP算法题(带扩充),php算法题扩充

Jun 13, 2016 am 08:58 AM

简单的PHP算法题(带扩充),php算法题扩充

简单的PHP算法题(待完善…)

 

只打印0

  具体个数由输入的参数n决定

  如n=5就打印00000

根据n值打印n个0

 

打印一行 0101010101010101010101 

  具体个数由输入的参数n决定

  如test.php?n=3打印010

根据n值打印010101…

 

实现1 00 111 0000 11111

  for if 实现

php for ($i = 0; $i $i++) { for ($j = 0; $j $i; $j++) { if ($i % 2 == 0) { echo '0'; } else { echo '1'; } } echo '
'; } ?> for&if语句实现

  for switch 实现

php for ($i = 0; $i $i++) { for ($j = 0; $j $i; $j++) { switch ($j % 2) { case '0': echo "0"; break; case '1': echo "1"; break; } } echo '
'; } ?> for&switch语句实现

  while if 实现

  while switch 实现

php $i = 0; while ($i ) { $j = 0; while ($j $i) { switch ($i % 2) { case 0: echo '0'; break; case 1: echo '1'; break; } $j++; } echo '
'; $i++; } ?> while&switch语句实现

 

实现0 01 010 0101……

 

实现0 01 012 0123 3210 210 10 0

 

做个计算器

  如test.php?a=1&b=2&operator=jia输出3

  如test.php?a=5&b=2&operator=jian输出3

  如test.php?a=2&b=5&operator=cheng输出10

  如test.php?a=6&b=3&operator=chu输出2

可处理加减乘除的四位一体计算函数

 

进阶:

  水仙花数

  冒泡排序法

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months 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)