?? combination.cpp
字號:
// combination.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include "Fraction.h"
//小于1000的數(shù)中約數(shù)最多的數(shù)是840,其約數(shù)個數(shù)為31(不包括1,便包括840)
/*************************************************************************\
* 操作系統(tǒng): 中文Win2K *
* 開發(fā)平臺: Visual C++ 6.0 *
* 執(zhí)行本程序之前,需要在執(zhí)行體的當前目錄下創(chuàng)建一名為data.txt的文本文件 *
* 文件格式如下: *
* *
* 4 *
* 1 2 *
* 19 45 *
* 13 51 *
* 59 121 *
* . . *
* . . *
* . . *
* *
* 第一行中4表示下面有4組測試數(shù)據(jù) *
* 緊接著每行包含2個整數(shù),代表分子和分母,小數(shù)為分子,大數(shù)為分母 *
* 所有數(shù)必需大于0,且每組數(shù)據(jù)中的兩個數(shù)不能相等 *
\*************************************************************************/
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++;//進行下一組測試數(shù)據(jù)
}
fclose(fp);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -