1.测试题目
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>题目</title>
</head>
<body>
<%
%>
<form action="111.jsp" method="get">
<h2>一、判断</h2><br>
<table>
<tr>
<td></td><td>正确</td><td>错误</td>
</tr>
<tr>
<td>1.在C语言中,为了结束由do-while语句构成的循环,while后 对圆括号中表达式的值应该是0</td><td> <input type="radio" name="pd1" id="pd1" value="1"></td><td><input type="radio" name="pd1" id="pd2"value="2"></td>
</tr>
<tr>
<td>2.对指针变量的初始化int a,tpe-ka,*pc=0;是正确的</td><td> <input type="radio" name="pd2"value="1"></td><td><input type="radio" name="pd2"value="2"></td>
</tr>
<tr>
<td>3.int a[3)[4]=((1),(5),(9));它的作用是将数组各行第一列的元素赋初值,其余元素值为0.</td><td> <input type="radio" name="pd3"value="1"></td><td><input type="radio" name="pd3"value="2"></td>
</tr>
<tr>
<td>4.do-while循环是先执行循环体语句,后判断表达式的值. </td><td> <input type="radio" name="pd4"value="1"></td><td><input type="radio" name="pd4"value="2"></td>
</tr>
<tr>
<td>5.在C程序中,无论是整数还是实数,都能准确无误地表示.</td><td> <input type="radio" name="pd5"value="1"></td><td><input type="radio" name="pd5"value="2"></td>
</tr>
</table>
<h2>二、选择</h2><br>
<table>
<tr><td colspan="4"> 1.()是构成C语言程序的基本单位。</td></tr>
<tr><td><input type="radio" name="xz1"value="1">A、函数</td><td><input type="radio" name="xz1"value="2">B、过程</td>
<td><input type="radio" name="xz1"value="3">C、子程序</td><td><input type="radio" name="xz1"value="4">D、子例程</td></tr>
<tr><td colspan="4"> 2.C语言程序从()开始执行。</td></tr>
<tr><td><input type="radio" name="xz2"value="1">A、程序中第一条可执行语句</td><td><input type="radio" name="xz2"value="2">B、程序中第一个函数</td>
<td><input type="radio" name="xz2"value="3"> C、程序中的 main 函数</td><td><input type="radio" name="xz2"value="4">D、包含文件中的第一个函数
大</td></tr>
<tr><td colspan="4"> 3.以下说法中正确的是()。</td></tr>
<tr><td> <input type="radio" name="xz3"value="1">A、C语言程序总是从第一个定义的函数开始执行</td><td><input type="radio" name="xz3"value="2">B、在C语言程序中,要调用的函数必须在 main( 函数中定义</td>
<td><input type="radio" name="xz3"value="3"> C、C语言程序总是从 main( q数开始执行</td><td><input type="radio" name="xz3"value="4">D、C语言程序中的main( 函数必须放在程序的开始部分</td></tr>
<tr><td colspan="4"> 4.下列关于C语言的说法错误的是( )</td></tr>
<tr><td> <input type="radio" name="xz4"value="1">A、C程序的工作过程是编辑、编译、连接、运行</td><td><input type="radio" name="xz4"value="2">B、C语言不区分大小写。</td>
<td><input type="radio" name="xz4"value="3"> C、C程序的三种基本结构是顺序、选择、循环</td><td><input type="radio" name="xz4"value="4">D、C程序从 main 函数开始执行</td></tr>
<tr><td colspan="4"> 5.下列正确的标识符是( )。</td></tr>
<tr><td> <input type="radio" name="xz5"value="1">A、-al</td><td><input type="radio" name="xz5"value="2">B、a[i]</td>
<td><input type="radio" name="xz5"value="3"> C、a2_i</td><td><input type="radio" name="xz5"value="4">D、int t</td></tr>
</table>
<h2>三、多选</h2><br>
1.以下叙述正确的是()。 <br>
<input type="checkbox" name="dx1"value="1">A、C语言严格区分大小写英文字母<br>
<input type="checkbox" name="dx1"value="2">B、C语言用”;"作为语句分隔符<br>
<input type="checkbox" name="dx1"value="3">C、C程序书写格式自由,一行内可以写几个语句,一个语句也可以写在几行上.<br>
<input type="checkbox" name="dx1"value="4">D、可以使用*… /对C程序中的任何部分作注释<br>
2.以下描述正确的是()<br>
<input type="checkbox" name="dx2"value="1">A、调用函数时,实参可以是表达式<br>
<input type="checkbox" name="dx2"value="2">B、调用函数时,实参与形参可以共用内存单元<br>
<input type="checkbox" name="dx2"value="3">C、调用函数时,将为形参分配内存单元<br>
<input type="checkbox" name="dx2"value="4">D、调用函数时,实参与形参的类型必须一致<br>
3.若以下选项中的变量已正确定义,则不正确的赋值语句是()。<br>
<input type="checkbox" name="dx3"value="1">A、x1-26.8%3<br>
<input type="checkbox" name="dx3"value="2">B、x=3*x+x<br>
<input type="checkbox" name="dx3"value="3">C、x3-0x12<br>
<input type="checkbox" name="dx3"value="4">D、x4=1+2=3;<br>
4.下列选项中是C语言合法标志符的有()。<br>
<input type="checkbox" name="dx4"value="1">A、good morning<br>
<input type="checkbox" name="dx4"value="2">B、main<br>
<input type="checkbox" name="dx4"value="3">C、stdio.h<br>
<input type="checkbox" name="dx4"value="4">D、8abc<br>
5.以下4个选项中,可以看作是一条语句的有()<br>
<input type="checkbox" name="dx5"value="1">A、)<br>
<input type="checkbox" name="dx5"value="2">B、a=0,b=0,c=0;<br>
<input type="checkbox" name="dx5"value="3">C、if(a>0);<br>
<input type="checkbox" name="dx5"value="4">D、if(b= =0) m=1;n=2;<br>
<input type="submit" value="提交">
</form>
</body>
</html>
运行结果:
2.测试结果:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>得分</title>
</head>
<body>
<% int sum=0;
String t1=request.getParameter("pd1");
String t2=request.getParameter("pd2");
String t3=request.getParameter("pd3");
String t4=request.getParameter("pd4");
String t5=request.getParameter("pd5");
String t6=request.getParameter("xz1");
String t7=request.getParameter("xz2");
String t8=request.getParameter("xz3");
String t9=request.getParameter("xz4");
String t10=request.getParameter("xz5");
String t11[]=request.getParameterValues("dx1");
String t12[]=request.getParameterValues("dx2");
String t13[]=request.getParameterValues("dx3");
String t14[]=request.getParameterValues("dx4");
String t15[]=request.getParameterValues("dx5");
if(t1==null)
{
}
if (t1==null)
{
out.print("<p style='color:blue'>1.应选正确</p>");
}
else if(t1.equals("1"))
{
out.print("<p style='color:green'>1.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>1.错误,应选正确</p>");
if (t2==null)
{
out.print("<p style='color:blue'>2.应选正确</p>");
}
else if(t2.equals("1"))
{
out.print("<p style='color:green'>2.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>2.错误,应选正确</p>");
if (t3==null)
{
out.print("<p style='color:blue'>3.应选正确</p>");
}
else if(t3.equals("1"))
{
out.print("<p style='color:green'>3.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>3.错误,应选正确</p>");
if (t4==null)
{
out.print("<p style='color:blue'>4.应选正确</p>");
}
else if(t4.equals("1"))
{
out.print("<p style='color:green'>4.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>4.错误,应选正确</p>");
if (t5==null)
{
out.print("<p style='color:blue'>5.应选错误</p>");
}
else if(t5.equals("2"))
{
out.print("<p style='color:green'>5.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>5.错误,应选错误</p>");
if (t6==null)
{
out.print("<p style='color:blue'>6.应选A</p>");
}
else if(t6.equals("4"))
{
out.print("<p style='color:green'>6.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>6.错误,应选A</p>");
if (t7==null)
{
out.print("<p style='color:blue'>7.应选C</p>");
}
else
if(t7.equals("3"))
{
out.print("<p style='color:green'>7.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>7.错误,应选C</p>");
if (t8==null)
{
out.print("<p style='color:blue'>8.应选C</p>");
}
else
if(t8.equals("2"))
{
out.print("<p style='color:green'>8.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>8.错误,应选C</p>");
if (t9==null)
{
out.print("<p style='color:blue'>9.应选B</p>");
}
else
if(t9.equals("4"))
{
out.print("<p style='color:green'>9.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>9.错误,应选B</p>");
if (t10==null)
{
out.print("<p style='color:blue'>10.应选C</p>");
}
else
if(t10.equals("2"))
{
out.print("<p style='color:green'>10.正确</p>");
sum+=5;
}
else
out.print("<p style='color:red'>3.错误,应选C</p>");
if (t11==null||t11.length<2)
{
out.print("<p style='color:blue'>11.应选A,B,C,D</p>");
}
else
if(t11[0].equals("1")&t11[1].equals("4"))
{
out.print("<p style='color:green'>11.正确</p>");
sum+=10;
}
else
out.print("<p style='color:red'>11.错误,应选A,B,C,D</p>");
if (t12==null||t12.length<3)
{
out.print("<p style='color:blue'>12.应选A,C,D</p>");
}
else
if(t12[0].equals("2")&t12[1].equals("3")&t12[2].equals("5"))
{
out.print("<p style='color:green'>12.正确</p>");
sum+=10;
}
else
out.print("<p style='color:red'>12.错误,应选A,C,D</p>");
if (t13==null||t13.length<4)
{
out.print("<p style='color:blue'>13.应选A,D</p>");
}
else
if(t13[0].equals("1")&t13[1].equals("2")&t13[2].equals("3")&t13[3].equals("4"))
{
out.print("<p style='color:green'>13.正确</p>");
sum+=10;
}
else
out.print("<p style='color:red'>13.错误,应选A,D</p>");
if (t14==null||t14.length<3)
{
out.print("<p style='color:blue'>14.应选A,B</p>");
}
else
if(t14[0].equals("1")&t14[1].equals("2")&t14[2].equals("4"))
{
out.print("<p style='color:green'>14.正确</p>");
sum+=10;
}
else
out.print("<p style='color:red'>14.错误,应选A,B</p>");
if (t15==null||t15.length<3)
{
out.print("<p style='color:blue'>15.应选A,B,C</p>");
}
else
if(t15[0].equals("1")&t15[1].equals("2")&t15[2].equals("4"))
{
out.print("<p style='color:green'>15.正确</p>");
sum+=10;
}
else
out.print("<p style='color:red'>15.错误,应选A,B,C</p>");
out.print("<p style='color:red;'><font size='100px;'>最后得分"+sum+"</font><p>");
%>
</body>
</html>
运行结果: