zoukankan      html  css  js  c++  java
  • Excel Tools For ZH

    #include "stdafx.h"
    #include "XQTools.h"
    #include <iostream>
    #include <string>
    #include <time.h>
    using namespace std;

    map<string,string> XQTools::mapTabDatas = map<string,string>();

    string GetLine()
    {
    char cTmp = 0;
    string sRes;
    do{
    cTmp = getchar();
    sRes += cTmp;
    }while(cTmp != ' ');
    return sRes;
    }

    bool XQTools::MapLineData()
    {
    char cTmp = 0;
    string sRes = "";

    string sKey = "";
    cin>>sKey;

    sRes += sKey;

    do{
    cTmp = getchar();
    sRes += cTmp;
    }while(cTmp != ' '&&cTmp!=EOF);
    XQTools::mapTabDatas[sKey] = sRes;
    return sRes.length()>20;
    }

    static string sHead = "";
    void XQTools::Init()
    {
    if(freopen("D://Source.tab","r",stdin));
    {
    sHead += GetLine();
    sHead += GetLine();
    sHead += GetLine();
    }
    while(MapLineData());
    return ;
    }

    void XQTools::WriteNewFile(string sFileName, string sMessage )
    {
    freopen(sFileName.c_str(),"w",stdout);
    cout<<sHead;

    string sYear = "";
    string sMon = "";
    int flag = 1;
    for(int i = 0 ; i < sMessage.length(); i ++)
    {
    if(flag == 1)
    {
    if(sMessage[i]!=' '&&sMessage[i] != ' '&& sMessage[i] !=13 && sMessage[i] != 0)
    sYear+= sMessage[i];
    }else if(flag == 2)
    {
    if(sMessage[i] == ' ' || sMessage[i] == ' '||sMessage[i] == 13)
    {
    if(sMon.length() > 0)
    AddLine(sYear,sMon);
    sMon = "";
    }else
    {
    sMon += sMessage[i];
    }
    }
    if(sMessage[i]==' ')
    {
    flag ++;
    if(flag == 3)
    {
    flag = 1;
    sYear = "";
    }
    }
    }
    cout<<flush;
    return ;
    }

    std::string XQTools::GetFileName()
    {
    //"D://解密后的图片.jpg";
    string sFileName = "D://";
    char sTmp[20];
    time_t Time = 0;
    time(&Time);
    struct tm Tm;
    localtime_s(&Tm,&Time);
    sprintf_s(sTmp,20,"%02d%02d%02d",Tm.tm_hour,Tm.tm_min,Tm.tm_sec);
    sFileName += sTmp;
    sFileName += ".tab";
    return sFileName;
    }

    void XQTools::AddLine(string sYear,string sMon)
    {
    string sDate = "";
    sDate += sYear + "年";
    sDate += sMon + "月";
    if(mapTabDatas.find(sDate)==mapTabDatas.end())
    {
    cout<<sDate<<" No Find"<<endl;
    }else
    {
    string sCout = mapTabDatas[sDate];
    cout << sCout;
    }
    }

    void CExcelToolsDlg::OnBnClickedOk()
    {
    // TODO: Add your control notification handler code here
    string sFileName = XQTools::GetFileName();
    CString csMessage ;
    GetDlgItem(IDC_EDIT1)->GetWindowText(csMessage);

    USES_CONVERSION;
    string sMessage = W2CA((LPCWSTR)csMessage);

    XQTools::WriteNewFile(sFileName,sMessage);
    system(sFileName.c_str());
    //OnOK();
    }

  • 相关阅读:
    Spring学习4_整合Hibernate进行数据库操作
    spring学习3_通过注解简单实现AOP
    Spring学习2_AOP通过XML配置简单实现
    Spring学习1_面向切面( AOP )实现原理
    hibernate学习6_session之clear与flush
    hibernate学习5_session之load与get区别
    hibernate学习4_openSession()与getCurrentSession()区别
    utf8汉字编码16进制对照
    Debug
    服务器设计过程中踩过的坑儿
  • 原文地址:https://www.cnblogs.com/clover-xuqi/p/9122080.html
Copyright © 2011-2022 走看看