search

Home  >  Q&A  >  body text

How to use for language

(1) Generate a file, which is required to have 1000 lines, each line is the number of lines in the line;

(2) Calculate the number of all characters in the file;

(3) All ten numbers 0 1 2 3 4 5 6 7 8 9 appear several times in the statistical file.


饮浮觞 zyq饮浮觞 zyq1912 days ago1491

reply all(2)I'll reply

  • 邓

    2019-11-11 15:56:51

    <?php $arr=array();$sum=0;for($i=0;$i<10;$i ){ $arr[$i]=0;}
    for( $i=1;$i<=1000;$i ){ echo $i.'<hr>'; $k=$i; for($j=0;$j<=3;$j ){ $ m=$k; 10;$i ){ echo $i.' appears: '.$arr[$i].'times'.'<hr>'; $sum =$arr[$i];}
    echo 'Total Characters: '.$sum.'piece';?>

    Take a rough look and this should be able to achieve the above three points. (Characters do not include spaces)

    reply
    0
  • ringa_lee

    ringa_lee2019-10-15 20:37:58

    for language?

    You are talking about a for loop, right? To achieve these three requirements?

    reply
    0
  • Cancelreply