ma.cpp

来自「用C++编写的产生文章的程序」· C++ 代码 · 共 58 行

CPP
58 行
字号
// ma.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "algorithm.h"
#include<iostream>
#include<fstream>

using std::cin ;
using std::cout;
int main(int argc,char *argv[])
{
	std::ifstream inFile;
   std::ofstream outFile;

   if (argc !=4) 
	   cout<<"格式 ma sourcefile destfile 最大单词量";
   else
      {
		inFile.open (argv[1]);
		if(inFile==NULL)
		{
			cout<<"源文件打不开";
			
		}
		else
		{
			outFile.open (argv[2]);
			if(outFile==NULL)
			  cout<<"目标文件打不开";
			else
			{
			   int nwords=atoi(argv[3]);
			   if(nwords<0)
                  cout<<"单词量必须大于0";
			   else
			   {    
				   algorithm a;
                    Prefix prefix;
				 for(int i=0;i<NPREF;i++)
					{
					 a.add(prefix,NONWORD);					
					}
             
			     a.build(prefix,inFile);
	             a.add(prefix,NONWORD);
              	 a.generate(nwords,outFile);
			   }
			}
		}
	  }
  
   const char *filename="F:\\1.txt";
   
  
  
	return 0;
}

⌨️ 快捷键说明

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