<script>
var array1=new Array ();
var array2=new Array ();
for (Var i=0;i<5;i++)
{
array1[i]=0;
Array2[i]=1;
}
for (Var i=1;i<5;i++)
{
Array2[i]=parseint (array2[i-1]) +1;
}
var fei=0;
var piao=0;
for (Var i=0;i<20;i++)
{
var value=prompt ("First" + (i+1) + "Individual start voting");
var valueint=parseint (value);
if (value!=null&&value!= "" &&!isnan (value) &&value%1==0&&valueInt>0&& VALUEINT<6)
{
Switch (valueint)
{
Case 1:
Array1[0]+=1;
Break
Case 2:
Array1[1]+=1;
Break
Case 3:
Array1[2]+=1;
Break
Case 4:
Array1[3]+=1;
Break
Case 5:
Array1[4]+=1;
Break
}
Piao+=1;
}
Else
{
Fei+=1;
}
}
for (Var i=0;i<10;i++)
{
for (Var j=0;j<=i;j++)
{
if (parseint (Array1[j]) >parseint (Array1[i]))
{
var a=array1[i];
ARRAY1[I]=ARRAY1[J];
Array1[j]=a;
var b=array2[i];
ARRAY2[I]=ARRAY2[J];
Array2[j]=b;
}
}
}
document.write ("Total votes: 20, invalidated:" +fei+ ", number of valid votes:" +piao+ "<br/>");
for (Var i=array1.length-1;i>=0;i--)
{
document.write (array2[i]+ "number of students ranked first" + (5-i) + ", the ticket is:" +array1[i]+ "<br/>");
}
/*if (A1>=A2&&A1>=A3&&A1>=A4&&A1>=A5)
{
Alert ("Class 1th is the Monitor");
}
if (A2>=A1&&A2>=A3&&A2>=A4&&A2>=A5)
{
Alert ("Class 2nd is the Monitor");
}
if (A3>=A1&&A3>=A1&&A3>=A4&&A3>=A5)
{
Alert ("Class 3rd is the Monitor");
}
if (A4>=A1&&A3>=A2&&A4>=A3&&A4>=A5)
{
Alert ("Class 4th is the Monitor");
}
if (A5>=A1&&A5>=A2&&A5>=A3&&A5>=A4)
{
Alert ("Class 5th is the Monitor");
}*/
</script>
JS Small case: 5 students voted for the squad leader