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

📄 longadd.cpp

📁 采用类来实现对任意长的数据进行相加 在Visual C++6.0 WinXp下编译通过
💻 CPP
字号:
// LongAdd.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "afx.h"
#include "conio.h"
#include "LongCal.h"
/*void pmain(int argc, char* argv[])
{
	CLongCal a,b;
	a.iniUseString("-1");
	b.iniUseString("10");
	a.Add(b);
	a.toString();
	//CString str("22");
	//printf("\n%d",str.GetLength());
	getch();
}
*/
int main(int argc, char* argv[])
{
	if(argc==1)
	{
		printf("格式:LongAdd 数据文件名!\r\n");
		return 0;
	}
	else if(argc>=3)
	{
		printf("参数太多!\r\n格式:LongAdd 数据文件名!\r\n");
		return 0;
	}
	else
	{
		CStdioFile hfile;
		if( !hfile.Open( argv[1], CFile::modeRead, NULL))
		{
			hfile.Close();
			printf("数据文件打开出错!请确认数据文件的存在!\r\n");
			return 1;

		}
		else
		{   
			CLongCal base("0");/////reverse format
			CLongCal tobase;
			CString str_tobase;
			while(hfile.GetPosition()<(hfile.GetLength()-1))
			{	
				hfile.ReadString(str_tobase);
			     if(str_tobase.IsEmpty())///blank  
					continue;
			    tobase.iniUseString(str_tobase);
				//if(tobase.isZero()) break;//
				base.Add(tobase);
			    
			}
			base.toString();

		}

     hfile.Close();
	}
	getch();
 return 2;
}


⌨️ 快捷键说明

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