注册 登录
编程论坛 C++教室

c++基础问题求救

memecha 发布于 2008-09-04 19:26, 640 次点击
为什么我老师编译不通过啊,,郁闷,,高手帮忙看看哈,,,很着急的

#include <iomanip.h>

using namespace std;

int main()
{
    string movieName=[255];
    double adultTicketPrice;
    double childTicketPrice;
    int numOfAdultTicket;
    int numOfChildTicket;
    double percentDonation;
    double grossAmount;
    double amountDonated;
    double netSaleAmount;

    
    cout<<fixed<<showpoint<<setprecision(2);

    cout<<"Enter movie name: "<<flush;
    cin.getline(&movieName[0],255,'0');
    cout<<endl;

    cout<<"Enter the peice of adult ticket: "<<flush;
    cin>>adultTicketPrice;
    cout<<endl;

    cout<<"Enter the peice of child ticket: "<<flush;
    cin>>childTicketPrice;
    cout<<endl;

    cout<<"Enter the number of the adult ticket: "<<flush;
    cin>>numOfAdultTicket;
    cout<<endl;

    cout<<"Enter the number of the child ticket: "<<flush;
    cin>>numOfChildTicket;
    cout<<endl;

    cout<<"Enter the percentDonation: "<<flush;
    cin>>percentDonation;
    cout<<endl<<endl;

    grossAmount=adultTicketPrice*numOfAdultTicket+childTicketPrice*numOfChilddTicket;
    amountDonated=grossAmount*percentDonation/100;
    netSaleAmount=grossAmount-amountDonated;


    cout<<"**************"
        <<"**************"<<endl;

    cout<<setfill('.')<<left<<setw(35)<<"Movie Name: "<<right<<" "<<movieName<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Number of Tickets Sold: "<<setfill(' ')<<right<<setw(10)<<numOfAdultTicket+numOfChildTicket<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Gross Amount: "<<setfill(' ')<<right<<" $"<<setw(8)<<grossAmount<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Percentage of Gross Amount Donated: "<<setfill(' ')<<right<<setw(9)<<percentDonation<<'%'<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Amount Donated: "<<setfill(' ')<<right<<" $"<<setw(8)<<amountDonated<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Net Sale: "<<setfill(' ')<<right<<" $"<<setw(8)<<netSaleAmount<<endl;

    return 0;
}
2 回复
#2
liaojuncong2008-09-04 20:24
建议
我建立你把string和 iomanip里的有关内容在看一遍吧!
string movieName=[255];

 cout<<fixed<<showpoint<<setprecision(2);

cout<<setfill('.')<<left<<setw(35)<<"Movie Name: "<<right<<" "<<movieName<<endl;

    cout<<setfill('.')<<left<<setw(35)<<"Number of Tickets Sold: "<<setfill(' ')  <<right<<setw(10)<<numOfAdultTicket+numOfChildTicket<<endl;
#3
wlj_hk2008-09-04 21:26
看不大懂.
1