1234567891011121314151617181920212223242526272829303132333435363738
#include<iostream> #include<stack> using namespace std; struct widgetRecord { int quantity; double price; widgetRecord(int q, double p): quantity(q), price(p) { } }; int main() { stack<widgetRecord> widgets; int q; double p; int N; cout << "Enter how many types of widgets recieved: " << endl; cin >> N; cout << endl << "Enter the quantity and prices of recieved widgets: " << endl; for (int i = 0; i < N; i++) { cout << endl << "Enter the quantity of item # " << (i + 1) << ": "; cin >> q; cout << "Enter the price for each item: "; cin >> p; widgets.push(widgetRecord(q,p)); cout << endl; } cout << endl << "Quantity : Prices" << endl; for (int i = 0; i < N; i++) { widgetRecord widget = widgets.top(); cout << endl << widget.quantity << " : " << widget.price << endl; widgets.pop(); } system("pause"); }