1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <sstream>
using namespace std;
struct Names
{
string DrinkName;
float Cost;
int NumDrink;
};
int main()
{
Names names[] =
{
{"Coca Cola", 0.75f, 20},
{"RootBeer", 0.75f, 20 },
{"LemonLime", 0.75, 20 },
{"GrapeSoda", 0.80, 20},
{"CreamSoda", 0.80, 20}
};
char buffer[256] = {0};
for (int i =0; i < 5; i++)
{
sprintf(buffer, "%d. %-15s %.2f %3d", i, names[i].DrinkName.c_str(), names[i].Cost, names[i].NumDrink);
cout << buffer << "\n";
}
}
| |