Copy Code code as follows:
Title: <br/>
There are n lines that can divide a plane up to a number of parts <br/><br/>
Number of lines: <input type= "text" id= "line"/><br/>
Inner intersection: <label id= "Innerpoint" ></label><br/>
Split number: <label id= "part" style= "Background:yellow;" ></label><br/>
<input type= "button" onclick= "Calculate ()" value= "calculation"/>
<script type= "Text/javascript" >
function calculate (line)
{
var line = document.getElementById (' line '). Value;
if (line = = "")
{
line = 0;
document.getElementById (' line '). Value = line;
}
var line = parseint (line);
var innerpoint = line * (line-1)/2;
var part = (Math.pow (line,2) + line)/2 + 1;//line + innerpoint + 1 equals (number of lines squared + lines)/2 + 1
document.getElementById (' Innerpoint '). innertext = Innerpoint;
document.getElementById (' part '). innertext = part;
}
</script>
Say the law:
① the most divided parts: line number + internal intersection points +1
The number of intersections within the ② = (line number-1) of the internal intersection point + (line number-1), the newly added line can be with the other than the line intersection points
③ uses recursion to find the inner intersection number and then ① the calculation
The above is normal mathematical thinking, the following say I use the line test knowledge, is my Code Dongdong
I have listed some of the available parameters for the 1~5 line:
The number of diplomatic points in the intersection of the number of lines
1 0 2 2
2 1 4 4
3 3 6 7
4 6 8 11
5 10 10 16
It turns out that diplomatic points are meaningless, twice times the number of straight lines.
and part number = line number + Internal intersection point +1
The number of intersection points within the number of adjacent lines constitute a arithmetic progression, this arithmetic progression tolerance is 1, 1-0=1,3-1=2,6-3=3,10-6=4, transverse look 1+0=1,2+1=3,3+3=6 ... but this still uses recursion. The number of corresponding internal intersections is required, So longitudinal look at the law, 2*1=2 3*2=6 4*3=12 ... exactly twice times the number of internal intersections.