另外用for或do....while循环语句编写都可以
第1个回答 推荐于2017-06-14
<?
$num=0;
for($i=1;$i<=100;$i+=2){
$num+=$i;
}
echo $num;
?>本回答被网友采纳
$num=0;
for($i=1;$i<=100;$i+=2){
$num+=$i;
}
echo $num;
?>本回答被网友采纳
第2个回答 2017-06-14
$c=0;
for($i=1;$i<=100;$i++)
{
if($i%2!=0)
{
$c+=$i;
}
}
echo $c;
for($i=1;$i<=100;$i++)
{
if($i%2!=0)
{
$c+=$i;
}
}
echo $c;
第3个回答 2010-05-08
<?php
$i=0;
$num=0;
while($i<=100){
if($i%2==1) $num+=$i;
$i++;
}
echo $num;
?>本回答被网友采纳
$i=0;
$num=0;
while($i<=100){
if($i%2==1) $num+=$i;
$i++;
}
echo $num;
?>本回答被网友采纳
第4个回答 2019-06-18
<?php
$i=0;
$num=0;
while($i<=100){
if($i%2==1)
$num+=$i;
$i++;
}
echo
$num;
?>
$i=0;
$num=0;
while($i<=100){
if($i%2==1)
$num+=$i;
$i++;
}
echo
$num;
?>
第5个回答 2019-05-05
<?php
$i=0;
$num=0;
while($i<=100){
if($i%2==1)
$num+=$i;
$i++;
}
echo
$num;
?>
$i=0;
$num=0;
while($i<=100){
if($i%2==1)
$num+=$i;
$i++;
}
echo
$num;
?>