| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 638 人关注过本帖
标题:c++基础问题求救
只看楼主 加入收藏
memecha
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-2-3
收藏
 问题点数:0 回复次数:2 
c++基础问题求救
为什么我老师编译不通过啊,,郁闷,,高手帮忙看看哈,,,很着急的

#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;
}
搜索更多相关主题的帖子: 基础 
2008-09-04 19:26
liaojuncong
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2008-4-26
收藏
得分:0 
建议
我建立你把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;
2008-09-04 20:24
wlj_hk
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-9-2
收藏
得分:0 
看不大懂.
2008-09-04 21:26
快速回复:c++基础问题求救
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045023 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved