【发布时间】:2016-04-01 07:51:43
【问题描述】:
我想在我的结构中找到一个元素(姓氏)
struct student
{
char name[20];
char surname[20];
int marks;
};
Ofc 从键盘定义向量和搜索元素
vector <student> v;
char search_surname[20];
我是按功能输入元素:
int size = v.size();
v.push_back(student());
cout << "Input name: " << endl;
cin >> v[size].name;
cout << "Input surname: " << endl;
cin >> v[size].surname;
cout << "Input marks: " << endl;
cin >> v[size].marks;
现在,例如,当我的结构中有三个姓氏(牛顿、爱因斯坦、帕斯卡)时,我想找到姓氏 newton 并用 newton 计算结构的所有详细信息(名字、姓氏、标记)。我不知道我该怎么做。
【问题讨论】:
标签: c++ algorithm vector struct find