毕业设计想做一个考试系统,达到一个批量导入考题的功能。。2008年奥运会在哪里举行? (知识点:奥运会-难易指数:1)选择题
A.中国(正确) B.美国 C.英国2008年奥运会将在什么时间举行?(知识点:奥运会举办时间-难易指数-1)填空题
8月8日要把以上内容分割成以下格式:问题1:2008年奥运会在哪里举行?
知识点:奥运会
考题类型:选择题
答案:A.中国 B.美国 C.英国
正确答案:A问题2:2008年奥运会将在什么时间举行?
知识点:奥运会举办时间
考题类型:填空题
正确答案:8月8日
就上面的样子,怎么才能实现。
A.中国(正确) B.美国 C.英国2008年奥运会将在什么时间举行?(知识点:奥运会举办时间-难易指数-1)填空题
8月8日要把以上内容分割成以下格式:问题1:2008年奥运会在哪里举行?
知识点:奥运会
考题类型:选择题
答案:A.中国 B.美国 C.英国
正确答案:A问题2:2008年奥运会将在什么时间举行?
知识点:奥运会举办时间
考题类型:填空题
正确答案:8月8日
就上面的样子,怎么才能实现。
解决方案 »
- 世界时间
- 如何纵向遍历Datatable ?
- 高手来,高分伺候,高难度挑战!!在线等!!
- 请问如何用程序修改EXCEL文件里的字体?
- 关于id绑定的问题
- 精简版C#的Bitmap对像没有Save()函数,那应该怎么办?
- C#如何为注册表某项的everyone修改权限?
- 为什么DataGrid里的删除按钮不能触发DataGrid的DeleteCommand事件?
- 在线等待:C#中自定义一个函数,有一参数object,我怎么得到这个object 什么控件?
- 高手:如何使DataGrid中指定的Column中的指定的Row的网格为只读状态?
- C#网页控件webbrower中的相对路径怎么表示?
- 在多个项目中怎样共享资源文件???
参考以下代码:// Regex_extract.cpp
// compile with: /clr
#using <System.dll>using namespace System;
using namespace System::Text::RegularExpressions;int main()
{
array<String^>^ address=
{
"[email protected]",
"[email protected]",
"treyresearch.net",
"[email protected]"
}; Regex^ emailregex = gcnew Regex("(?<user>[^@]+)@(?<host>.+)"); for (int i=0; i<address->Length; i++)
{
Match^ m = emailregex->Match( address[i] );
Console::Write("\n{0,25}", address[i]); if ( m->Success )
{
Console::Write(" User='{0}'",
m->Groups["user"]->Value);
Console::Write(" Host='{0}'",
m->Groups["host"]->Value);
}
else
Console::Write(" (invalid email address)");
} Console::WriteLine("");
return 0;
}
2、[写入库],显示在页面(窗体);
3、答完,计分;
private void getText(string text)
{
string temp = "";
MatchCollection mats = Regex.Matches(text, @"^.*?知识点.*?\r\n.*?\r\n", RegexOptions.Multiline);
int count = 1;
foreach (Match mat in mats)
{
temp += "题目" + count.ToString() + ":" + Regex.Match(mat.Value, @"^.*?(?=(\(知识点))").ToString()+"\r\n";
temp += Regex.Match(mat.Value, @"知识点:.*?(?=(-))").ToString() + "\r\n";
if (Regex.Match(mat.Value, @"(?<=(\))).*").ToString().Trim() == "选择题")
{
temp += "考题类型:" + "选择题" + "\r\n";
temp += "答案:" + Regex.Match(mat.Value, @"(?<=\n).*").ToString().Replace("(正确)", "")+"\r\n";
temp += "正确答案:" + Regex.Match(mat.Value, @"\w+(?=.*正确)").ToString()+"\r\n";
}
if (Regex.Match(mat.Value, @"(?<=(\))).*").ToString().Trim() == "填空题")
{
temp += "考题类型:" + "填空题" + "\r\n";
temp += "正确答案:" + Regex.Match(mat.Value, @"(?<=\n).*").ToString() + "\r\n";
}
//temp += Regex.Match(mat.Value, @"(?<=\. ).*").ToString() + "\r\n"; //temp += Regex.Match(mat.Value, @"(?<=switchport access vlan )\d*").ToString() + "\r\n";
count++;
}
return temp ;}
using(StreamReader sr= new StreamReader("路径"))
{
while (sr.Read(content, 0, content.Length) > 0)
{
conStr += encoding.GetString(content);
}}
读文件
using(StreamWriter sr= new StreamWriter("路径"))
{
sr.Write(content, 0, content.Length);
}
写文件
我只写个txt 的文件
List<String> lis= new List<string>();
lis.add("问题1:2008年奥运会在哪里举行?");
lis.add("知识点:奥运会" );
lis.add(问题1:2008年奥运会在哪里举行?);
lis.add("考题类型:选择题 ");
lis.add("答案:A.中国 B.美国 C.英国 ");
lis.add("正确答案:A ");
lis.add("问题2:2008年奥运会将在什么时间举行?");
lis.add("知识点:奥运会举办时间");
lis.add("考题类型:填空题 ");
lis.add("正确答案:8月8日 ");using(StreamWriter sr= new StreamWriter("路径"))
{
for(int i=0;i<lis.Count;i++)
{
sr.Write(lis[i], 0, lst[i].Length);
}
}
//问题1:2008年奥运会在哪里举行?
//知识点:奥运会
//考题类型:选择题
//答案:A.中国 B.美国 C.英国
//正确答案:A //问题2:2008年奥运会将在什么时间举行?
//知识点:奥运会举办时间
//考题类型:填空题
//正确答案:8月8日