vector_平行向量 - waiting...'s Blog
vector_平行向量
-
#include <iostream>
-
#include <string>
-
#include <vector>
-
using namespace std;
-
-
int main()
-
{
-
vector<string> names;
-
vector<double> prices;
-
vector<int> scores;
-
-
bool more = true;
-
string name;
-
double price;
-
int score;
-
string remainder, answer;
-
while (more)
-
{
-
cout << "Please enter the name: ";
-
cin >> name;
-
names.push_back(name);
-
cout << "Please enter the price: ";
-
cin >> price;
-
prices.push_back(price);
-
cout << "Please enter the score: ";
-
cin >> score;
-
scores.push_back(score);
-
getline(cin, remainder);
-
cout << "Do you want enter more information(y/n): ";
-
getline(cin, answer);
-
if (answer != "y" && answer != "Y")
-
more = false;
-
}
-
-
for (unsigned int i = 0; i < names.size(); i++)
-
cout << names[i] << " " << prices[i] << " " << scores[i] << endl;
-
return 0;
-
}