|
二)
2.1
#include<iostream.h>voidmain()
{//本题原考虑在16位机器上实验目前多为32位机器,故已过时。inta=42486;
cout<<oct<<a<<endl
<<hex<<a<<endl;unsignedb=42486;
cout<<dec<<(signed)b<<endl;}
2.2
#include<iostream.h>#include<iomanip.h>
constdoublepi=3.1415926;voidmain(){
doubleradius1,radius2;
cout<<"pleaseinputtwonumbers:\n";cin>>radius1>>radius2;
cout<<setw(10)<<pi<<setw(10)<<radius1
<<setw(10)<<(pi*radius1*radius1)<<endl<<setw(10)<<pi<<setw(10)<<radius2
<<setw(10)<<(pi*radius2*radius2)<<endl;
}
2.3
#include<iostream.h>#include<iomanip.h>
constdoublee=2.718281828;voidmain(){
cout<<setprecision(10)<<e<<endl
<<setiosflags(ios::fixed)<<setprecision(8)<<e<<endl<<setiosflags(ios::scientific)<<e<<endl;
}
2.4
#include<iostream.h>
|
|