acm练习(四)

----------输出格式--------

#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout.width(9);
cout.setf(ios::left);
cout<<a;
cout.width(9);
cout.setf(ios::left);
cout<<a*a;
cout.width(9);
cout.setf(ios::left);
cout<<a*a*a<<endl;
cout.width(9);
cout.setf(ios::left);
cout<<b;
cout.width(9);
cout.setf(ios::left);
cout<<b*b;
cout.width(9);
cout.setf(ios::left);
cout<<b*b*b<<endl;
cout.width(9);
cout.setf(ios::left);
cout<<c;
cout.width(9);
cout.setf(ios::left);
cout<<c*c;
cout.width(9);
cout.setf(ios::left);
cout<<c*c*c<<endl;
return 0;
}

--------输出保留两位小数---------

#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
float m;
cin>>m;
cout<<setiosflags(ios::fixed)<<setprecision(2)<<m*6.5573<<endl;
return 0;
}

posted @ 2015-03-25 22:15  BugsTerminator  阅读(119)  评论(0编辑  收藏  举报