c++ 很简单的个程序,怎么不能正常运行啊?

来源:百度知道 编辑:UC知道 时间:2024/05/15 01:22:45
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
string date;
string isbn;
string title;
int quantity;
double price, total;

cout << " Serendipity Booksellers" << endl;
cout << " Cashier Module" << endl;
cout << "Date: " ;
getline(cin,date);
cout << "Quantity of Book: " ;
cin >> quantity;
cout << "ISBN: " ;
getline(cin,isbn);
cout << "Title: " ;
getline(cin,title);
cout << "Price: " ;
cin >> price;

total=price*quantity*0.06;
cout << " \n\nSerendipity Booksellers" << endl;
cout << " Date: " << date <<endl;
cout <

输入用cin就行,不需用getline()。

你是不是想把表头和输出的条目对齐?
把表头和条目的输出格式设成一样就行了。

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
string date;
string isbn;
string title;
int quantity;
double price, total;

cout << " Serendipity Booksellers" << endl;
cout << " Cashier Module" << endl;
cout << "Date: " ;
cin >> date;
cout << "Quantity of Book: " ;
cin >> quantity;
cout << "ISBN: " ;
cin >> isbn;
cout << "Title: " ;
cin >> title;
cout << "Price: " ;
cin >> price;

total=price*quantity*0.06;
cout << " \n\nSerendipity Booksellers" << end