实验8CSV数据文件操作

上传人:碎****木 文档编号:220861279 上传时间:2021-12-09 格式:DOCX 页数:14 大小:110.73KB
返回 下载 相关 举报
实验8CSV数据文件操作_第1页
第1页 / 共14页
实验8CSV数据文件操作_第2页
第2页 / 共14页
实验8CSV数据文件操作_第3页
第3页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《实验8CSV数据文件操作》由会员分享,可在线阅读,更多相关《实验8CSV数据文件操作(14页珍藏版)》请在金锄头文库上搜索。

1、试验 8 CSV 数据文件操作试验目的:了解 CSV 格式数据记录文件构造,把握大数据量记录的查询技巧。试验内容:编程设计一个成语接龙玩耍。具体要求如下:1、推断输入词语是否是成语;2、可以推断是否符合成语接龙玩耍规章;3、可以实现提示功能;4、可以实现显示成语含义的功能;试验步骤:基于 MFC 对话框应用程序实现。1、界面设计2、控件变量定义3、创立“Idiom”类31“Idiom.h”文件内容/ Idiom.h: interface for the Idiom class./#include #if !defined(AFX_IDIOM_H DED_)C9A16E11_19F4_4BCF_

2、B7D0_4CCF4FA5AE2DINCLU#define AFX_IDIOM_HC9A16E11_19F4_4BCF_B7D0_4CCF4FA5AE2DINCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000class Idiomprivate:CString Idiom130805;/成语CString Idiom230805;/读音CString Idiom330805;/释义CString Idiom43041;/首字unsigned long Idiom53041;/首字在大表位置public:void Help(CSt

3、ring C1,int *nIndex1); void Help(CString C1);int Distinguish(CString nC1);void Solitaire(CString C1,CString C2,int *nIndex1);void GetIdiom(long Index,CString *txt1,CString *txt2,CString *txt3); Idiom();virtual Idiom();#endif/ !defined(AFX_IDIOM_H ED_)32“Idiom.cpp”文件内容C9A16E11_19F4_4BCF_B7D0_4CCF4FA5

4、AE2DINCLUD/ Idiom.cpp: implementation of the Idiom class./#include “stdafx.h“ #include “shiyan3.h“ #include “Idiom.h“#ifdef _DEBUG #undef THIS_FILEstatic char THIS_FILE= #define new DEBUG_NEW #endifFILE;/ Construction/Destruction/Idiom:Idiom()CStdioFile file1; CString str;unsigned long row1=0;int co

5、unt=0; int index;file1.Open(_T(“a1.csv“),CFile:modeRead); while(file1.ReadString(str)/str = str.Trim(_T(“ “); str.TrimLeft(); str.TrimRight();count=0;index = str.Find(_T(“,“);while (index != -1 & row130804)switch(count)case 0:Idiom1row1=_T(str.Left(index); break;case 1:Idiom2row1=_T(str.Left(index);

6、 break;count+;str=str.Right(str.GetLength()-index-1); index = str.Find(_T(“,“);if(row130804)Idiom3row1=_T(str);row1+;file1.Close();/-file1.Open(_T(“a2.csv“),CFile:modeRead);row1=0;while(file1.ReadString(str)/str = str.Trim(_T(“ “); str.TrimLeft(); str.TrimRight();count=0;index = str.Find(_T(“,“);whi

7、le (index != -1 & row13040)switch(count)case 0:Idiom4row1=_T(str.Left(index); break;count+;str=str.Right(str.GetLength()-index-1); index = str.Find(_T(“,“);if(row1=0 & Index30840)n1=n1/2;*txt1=Idiom1n1;*txt2=Idiom2n1;*txt3=Idiom3n1;void Idiom:Solitaire(CString C1,CString C2,int *nIndex1)CString nC1,

8、nC2; int n1;nC1=C1.Right(2);/当前成语的最终一个字nC2=C2.Left(2); /答案词的第一个字if(nC1=nC2)n1=0;/接语成功*nIndex1=Distinguish(C2);int Idiom:Distinguish(CString nC1)CString nC2;int n1,n2,m1,m2;nC2=nC1.Left(2); /输入词的第一个字for (n1=0;n13040;n1+)if(Idiom4n1=nC2)break;if (n13040)m1=Idiom5n1-1; m2=Idiom5n1+1;for (n2=m1;n2m2;n2+

9、)if(Idiom1n2=nC1)return(n2);return(-1);void Idiom:Help(CString C1)CString nC1,nC2; int n1,n2,n3,m1,m2;nC1=C1.Right(2); /输入词的最终一个字for (n1=0;n13040;n1+)if(Idiom4n1=nC1)break; n3=0;if (n13040)m1=Idiom5n1-1; m2=Idiom5n1+1-1;for (n2=m1;n2m2;n2+)if(n30)MessageBox(0,nC2,“合符要求的成语如下“,1);elseMessageBox(0,“没有合符要求的成语“,“警告“,1);void Idiom:Help(CString C1, int *nIndex1)CString nC1,nC2; int n1,m1,m2;nC1=C1.Right(2); /输入词的最终一个字for (n1=0;n13040;n1+)if(Idiom4n1=nC1)break;if (n13040)/*nIndex1=Idiom5n1-1; m1=Idiom5n1-1; m2=Idiom5n1+1-2;m2=m2-m1; if (m20)myIdiom.GetIdiom(n1,&c1,&c2,&c3); m_ed1=c1; m_ed3.Format(“%s

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 教育/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号