Sub defen()
Dim a As String, b As String
For n = 1 To 3 '需要改下这里,这是行数
a = fenzu(Cells(n, 1))
paixu a
b = fenzu(Cells(n, 2))
paixu b
If a = b Then
Cells(n, 3) = 2
Else
If InStr(1, a, b) Then
Cells(n, 3) = 1
Else
Cells(n, 3) = 0
End If
End If
Next
End Sub
'防止答案或者标准答案顺序不对,按字母顺序排序
Sub paixu(shu As String)
Dim a, c
Dim i As Integer, temp
a = Split(shu, ",")
For i = 0 To UBound(a) - 1
If (a(i) >a(i + 1)) Then '若是递减,改为a(i)<a(i+1)
temp = a(i)
a(i) = a(i + 1)
a(i + 1) = temp
End If
Next
shu = Join(a, "")
End Sub
'为了排序,每个字母之间插入逗号
Function fenzu(t As Range) As String
Dim a As String, b As String
a = ""
b = UCase(t)
For m = 1 To Len(b)
a = a &Mid(b, m, 1) &","
Next
fenzu = Mid(a, 1, Len(a) - 1)
End Function
就帮你写一下好了 我的php文件名称是test.php 你可以改成自己的php文件名称 好像是4zuoy2.php
<!DOCTYPE html><html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<title>测试</title>
</head>
<body>
<form action="test.php" type="post">
<div class="select-area">
<input type="checkbox" name="program[]" value="1" />AJAX
<input type="checkbox" name="program[]" value="2" />PHP
<input type="checkbox" name="program[]" value="3" />FLASH
<input type="checkbox" name="program[]" value="4" />ASP
<input type="checkbox" name="program[]" value="5" />JSP
</div>
<div class="submit-button">
<input type="submit" class="submit">确定</button>
</div>
</form>
</body>
</html>
<?php
!empty($_POST['program']) ? $program = $_POST['program'] : ''
if ($program) {
//遍历传递过来的是数组
if (in_array(2, $program)&&in_array(4,$program)&&in_array(5,$program)) {
echo '正确'
}elseif (!in_array(2, $program) || !in_array(4,$program) || !in_array(5,$program)) {
echo '回答不全!'
}else{
echo '错误!'
}
}
?>
#include<stdio.h>#define MaxLen 4
void main()
{
int i=0//题号
int count[MaxLen]//记录选项被选的次数
char ch//题目选项
for(int j=0j<MaxLenj++)
count[j]=0
printf("请输入您的选项<选项在ABCD中>,输入#结束输入\n")
printf("第%d题:\n",++i)
scanf("%c",&ch)
getchar()//接收键盘输入的空格
while(1)
{
if(ch=='#')//输入#直接跳出
break
printf("第%d题:\n",++i)
switch(ch)
{
case 'A':
case 'a':
count[0]++
break
case 'B':
case 'b':
count[1]++
break
case 'C':
case 'c':
count[2]++
break
case 'D':
case 'd':
count[3]++
break
default:
printf("对不起您的输入不正确,请重新输入")//输入不正确时重新输入
i--//题号还原
break
}
printf("请输入您的选项<选项在ABCD中>\n")
scanf("%c",&ch)
getchar()//接收键盘输入的空格
}
printf("A被选%d次,B被选%d次,C被选%d次,D被选%d次\n",count[0],count[1],count[2],count[3])//输出abcd被选的次数
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)