码迷,mamicode.com
首页 > Windows程序 > 详细

winform文本内容对比

时间:2021-07-02 16:19:59      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:wing   for   array   button   题目   windows   获取   raw   ace   

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{

}

private void richTextBox2_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
//题目计数,共75题
int count = 0;
//得分计数,满分115
double piont = 0;
//用于存放获取填写的答案
List<string> answer = new List<string>();
//真实的题库答案,用于对比找出正确与错误的答案
List<string> question = new List<string> { "A", "C", "C", "A", "B", "D", "D", "A", "C", "A", "B", "A", "A", "C", "A", "D", "C", "D", "A", "D", "A", "B", "B", "C", "A", "B", "D", "D", "C", "A", "D", "C", "A", "C", "C", "T", "K", "H", "E", "A", "C", "D", "N", "R", "G", "B", "L", "P", "I", "Q", "F", "M", "J", "S", "O", "A", "A", "C", "D", "D", "D", "D", "A", "A", "B", "C", "C", "B", "A", "A", "B", "B", "A", "C", "B" };
List<string> solve = new List<string> { "A", "C", "C", "A", "B", "D", "D", "A", "C", "A", "B", "A", "A", "C", "A", "D", "C", "D", "A", "D", "A", "B", "B", "C", "A", "B", "D", "D", "C", "A", "D", "C", "A", "C", "C", "T", "K", "H", "E", "A", "C", "D", "N", "R", "G", "B", "L", "P", "I", "Q", "F", "M", "J", "S", "O", "A", "A", "C", "D", "D", "D", "D", "A", "A", "B", "C", "C", "B", "A", "A", "B", "B", "A", "C", "B" };
//用于存放错题
List<string> wrong = new List<string>();
char[] c = richTextBox1.Text.ToCharArray();
foreach (char i in c)
{
if(i.ToString() != "\n")
{
answer.Add(i.ToString());
}
}
while (count < 75)
{
//答案正确,则加分
if (answer[count] == question[count])
{
if (count < 20)
{
piont += 1.5;
}
else if (count < 35)
{
piont += 1;
}
else if (count < 55)
{
piont += 1.5;
}
else if (count < 75)
{
piont += 2;
}
//count += 1;
}
//回答错误,连带题号计入错题集
else
{
//count += 1;
if (count < 20)
{
wrong.Add("\n错题号为:" + (count + 1) + "\n" + "您填的错误选项为:" + answer[count] + "\n" + "正确选项为:" + question[count] + "\n" + "该题目扣1.5分\n" + "该题解析:" + solve[count] + "\n");
}
else if (count < 35)
{
wrong.Add("\n错题号为:" + (count + 1) + "\n" + "您填的错误选项为:" + answer[count] + "\n" + "正确选项为:" + question[count] + "\n" + "该题目扣1分\n" + "该题解析:" + solve[count] + "\n");
}
else if (count < 55)
{
wrong.Add("\n错题号为:" + (count + 1) + "\n" + "您填的错误选项为:" + answer[count] + "\n" + "正确选项为:" + question[count] + "\n" + "该题目扣1.5分\n" + "该题解析:" + solve[count] + "\n");
}
else if (count < 75)
{
wrong.Add("\n错题号为:" + (count + 1) + "\n" + "您填的错误选项为:" + answer[count] + "\n" + "正确选项为:" + question[count] + "\n" + "该题目扣2分\n" + "该题解析:" + solve[count] + "\n");
}
}
count += 1;
//Task.Delay(200);
}
richTextBox2.AppendText("选择题总分为:115 分" + "\n");
richTextBox2.AppendText("您的选择题得分为:" + piont + " 分\n");
count = 0;
while (count < wrong.Count)
{
richTextBox2.AppendText(wrong[count]);
count += 1;
}
}
}
}

winform文本内容对比

标签:wing   for   array   button   题目   windows   获取   raw   ace   

原文地址:https://www.cnblogs.com/Lee597/p/14962542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!