这第二篇并没有涉及什么算法,唯一的公式也已抛出,所以没什么难度,不过对于我来说,如何用C++来控制输出格式还很陌生.
c++输入输出格式,
http://blog.sina.com.cn/s/blog_76163aba0100ppk1.html
上代码
#include <iostream>
#include <iomanip>
using namespace std;
#define RATE 3.28
#define WIDTH 6
double FeetToMeter(int feet, int meter)
{
return (feet*10+meter)/RATE;
}
void main()
{
int i,j;
cout<<setw(WIDTH)<<"I2M";
for (i = 0; i< 10; i++)
{
cout<<setw(WIDTH)<<i;
}
cout<<endl;
//cout.setf(ios::fixed);
for ( i = 0; i< 10 ; i++)
{
cout<<setw(WIDTH)<<i;
for ( j = 0 ; j < 10; j++)
{
cout<<setprecision(3)<<setw(WIDTH)<<FeetToMeter(i,j);
}
cout<<endl;
}
}