search
Homephp教程php手册简单的PHP算法题(带扩充),php算法题扩充

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

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software