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();
    }

  • 相关阅读:
    vue项目进行时,script标签中,methods事件中函数使用的async/await
    css阴影——box-shadow
    vue报错——Module not found: Error: Can't resolve 'less-loader sass' in ...
    vue组件如何引入外部.js/.css/.scss文件
    获得汉字的拼音或者拼音简写
    model转XML
    sql server 添加表注释、字段注释
    (转)SQL Server 监控统计阻塞脚本信息
    系统首页右下角弹框
    DropDownListExtend控件
  • 原文地址:https://www.cnblogs.com/clover-xuqi/p/9122080.html
Copyright © 2011-2022 走看看