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

📄 combination.cpp

📁 用排序方法解决埃及分数问题的Visual C++ 实现
💻 CPP
字号:
// combination.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include "Fraction.h"

//小于1000的数中约数最多的数是840,其约数个数为31(不包括1,便包括840)
/*************************************************************************\
*	操作系统: 中文Win2K                                                  *
*	开发平台: Visual C++ 6.0                                             *
*	执行本程序之前,需要在执行体的当前目录下创建一名为data.txt的文本文件 *
*	文件格式如下:                                                       *
*	                                                                     *
*	4                                                                    *
*	1 2                                                                  *
*	19 45                                                                *
*	13 51                                                                *
*	59 121                                                               *
*	.  .                                                                 *
*	.  .                                                                 *
*	.  .                                                                 *
*                                                                        *
*   第一行中4表示下面有4组测试数据                                       * 
*   紧接着每行包含2个整数,代表分子和分母,小数为分子,大数为分母        * 
*   所有数必需大于0,且每组数据中的两个数不能相等                         *
\*************************************************************************/
int main(int argc, char* argv[])
{
	CProperFractionReduce pfr;
	int idx,x,y,count;
	FILE *fp;

	fp=fopen("data.txt","rt");
	if(fp!=NULL)
	{
		fscanf(fp,"%d",&count);	idx=0;
		while(idx<count)
		{
			fscanf(fp,"%d",&x); fscanf(fp,"%d",&y);
			if(x==y)printf("Must be proper fraction!\n");
			else if(x<0||y<0)printf("Must be plus!\n");
			else if(x==0||y==0)printf("Must not be zero!\n");
			else pfr.workitout(x,y);

			idx++;//进行下一组测试数据
		}
		fclose(fp);

	}
	return 0;
}

⌨️ 快捷键说明

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