print?<PRE class=cpp name="code">#include <iostream> #include <iomanip> using namespace std; void main() { char bookname[100];double price;int counts; cout << "請輸入書名:"<< endl; cin>>bookname; cout << "請輸入單價:"<< endl; cin>>price; cout << "請輸入銷售數量:"<< endl; cin>>counts; cout<<"使用狀態標志和成員函數進行格式化輸出"<<endl; cout<<"《"<<bookname<<"》:"; cout.width(5); //單價顯示寬度為5個字符 cout.fill('*'); //寬度不滿用*字符填充 cout<<price<<"(單價) "; //按照上面的格式設置輸出 #ifdef scientific cout.setf(ios::scientific); //用科學記數法輸出銷售額 cout.precision(3); //保留3位精度 #else cout<<std::fixed; //不使用科學計數法輸出 cout<<price*counts<<"(銷售額) "; #endif cout.setf(ios::showpos|ios::left); //顯示銷售數量,帶有正負號、左對齊 cout<<counts<<"(銷售數量)"<<endl; cout<<"使用流操作符進行格式輸出"<<endl; cout<<"《"<<bookname<<"》:" <<setw(5)<<setfill('*')<<price<<"(單價) " <<scientific<<setprecision(3)<<fixed<<price*counts<<"(銷售額) " <<showpos<<left<<counts<<"(銷售數量)"<<endl; cin>>bookname; }</PRE><BR> <BR> <PRE></PRE> <P><SPAN style="FONT-SIZE: 18px">《VC++6.0示例程序光盤》實例代碼</SPAN></P>