WHU-Problem 1004 - Noah's Ark

#include
#include
#include 
#include 
#define threshod 1e-9
using namespace std;


double change(double num, string c)
{
	double k = 1.0;
	if (c=="meters")k = 100.0;
	if (c=="cubits")k = 45.72;
	if (c=="feet")  k = 30.48;
	if (c=="inches")k = 2.54;
	num = num*k;
	return num;
}

int main()
{
	int i = 0;
	string output[10000];
	double length=0, width=0, height=0;
	//char dlength[20], dwidth[20], dheight[20];
	string dlength, dwidth, dheight;
	while (cin >> length >> dlength)
	{
		i++;
		cin >> width >> dwidth;
		cin >> height >> dheight;
		length=change(length,dlength);
		width=change(width,dwidth);
		if (fabs(length - width) < threshod)
			cout << "Spin" << endl;
		else
		{
			if (fabs((length - 6 * width)) < threshod)
				cout << "Excellent" << endl;
			else
				cout << "Neither" << endl;
		}
		cout << endl;
	}
	return 0;
}


疑惑:cout<

用while(1)与while(cin>>a)作循环会存在不同

你可能感兴趣的:(算法)