⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staticdll.cpp

📁 汉字统计程序
💻 CPP
字号:
// Staticdll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "staticdll.h"
#include <fstream.h>

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{

    return TRUE;
}

/*

			unsigned short jj,kk;
			for(int j=0;j<72;j++)
			{
				
				jj=0x30+j;
				for(int k=0;k<94;k++)
				{
					
					kk=0x21+k;

					kk=(jj<<8)|(kk);
					kk=kk|0x8080;

					out[k+94*j].incode=kk;
					out[k+94*j].cishu=0;
				}
			}
*/
	unsigned long   count=0;
	long int        high=0;
	STATIC			out[6763];


extern "C" __declspec(dllexport) void fStaticdll(char *filename,int ff)
{
	
		
		
		ifstream infile;

		int fc=0;
		//char FullFileName[20][MAX_PATH];
		//GetFullPathName(filename[fc],MAX_PATH,FullFileName[fc],0);
		

while((fc<ff))
{
	cout<<(filename+20*fc)<<endl;
	infile.open(filename+20*fc);
	if(!infile)
	{
		MessageBox(NULL,"can't open a input file","File Open Error",MB_ICONERROR);
		break;
	}


	


		
	
		 unsigned char  ch;
		 bool bfind;
		 
		 unsigned short aa,bb;
	     unsigned char lch;

		while(!infile.eof()&&(ch=infile.get()))
		{
			
			
				if(ch>0x80)
				{
					
				
					if(!infile.eof()&&(lch=infile.get())>0x80)
					{

					aa=ch;
					bb=lch;
					bb=(aa<<8)|(bb&0x00ff);

					//start tongji(0xb0a1~0xf7fe)
					
						if(bb<0xb0a1||bb>0xf7fe)
								continue;

					
						/*
						unsigned char ss[3];
						ss[0]=ch;
						ss[1]=lch;
						ss[2]='\0';
						
						outfile<<'\t'<<setiosflags(ios::showbase)
							<<ss<<','
							<<hex<<bb
							<<','<<dec<<bb
							<<endl;
						*/
						count++;
					    
						bfind=false;
						for(int low=0;low<high;low++)
						{
							if(bb==out[low].incode)
							{
								out[low].cishu+=1;
								bfind=true;
								break;
							}
						}
						if(!bfind)
						{
							out[high].cishu++;
							out[high].incode=bb;
							high++;
						}

					/*int low=0,mid=high/2;
					while(low<=high&&mid<=high&&mid>=low)
					{
						

						if(bb==out[low].incode)
						{
							
							out[low].cishu+=1;
						}
						 if(bb==out[high].incode)
						{
							//count++;
							out[high].cishu++;
						}
						 if(bb==out[mid].incode)
						{
							count++;
							out[mid].cishu++;
						}
						 if(bb<out[mid].incode)
						 {
							 high=mid-1;
							 low++;
							 
						 }
						 else if(bb>out[mid].incode)
						 {
							 low=mid+1;
							 high--;
						 }
						 
						mid=(high-low)/2+low;
					}//while:find the match word,either recur next;
					*/
				
					}//if
				
					
			
				}//if
			
		//	continue;
		}//while(!infile.eof())

		
	 infile.close();
	 fc++;
}//while(filename[ff])
}//end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -