Добавил:
Sputnik
Помощь с лабораторными, контрольными практическими и курсовыми работами по:
- Инженерной и компьютерной графике
- Прикладной механике
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:2 сем 1 курс С++ / ЛР 1 / main
.cpp#include <iostream>
#include <cstdlib>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
struct product
{
string name;
string proizvoditel;
int age;
int cena;
int count;
};
int main() {
vector <product> data;
cout << "Enter the data"<<endl;
int n;
cin>>n;
for(int i=0; n>i; i++){
product product_;
cout << "Enter the name"<<endl;
cin>>product_.name;
cout << "Enter the manufacturer"<<endl;
cin>>product_.proizvoditel;
cout << "Enter storage period"<<endl;
cin>>product_.age;
cout << "Enter price"<<endl;
cin>>product_.cena;
cout << "Enter the count"<<endl;
cin>>product_.count;
// сltknm строки для проиводителя и прочи членов структуры cout and cin
data.push_back(product_);
}
cout << "Enter the name for reseach"<<endl;
string qwerty;
cin >> qwerty;
for (int i=0; data.size()>i; i++) {
if (data[i].name==qwerty){
cout<<data[i].name<< endl;
cout<<data[i].proizvoditel<< endl;
cout<<data[i].age<< endl;
cout<<data[i].cena<< endl;
cout<<data[i].count<< endl;
// по имени cout
}
}
cout << "Enter the prise for reseach"<<endl;
int cena;
cin >> cena;
for (int i=0; data.size()>i; i++) {
if ((data[i].name==qwerty) and (data[i].cena<=cena )){
cout<<data[i].name<< endl;
cout<<data[i].proizvoditel<< endl;
cout<<data[i].age<< endl;
cout<<data[i].cena<< endl;
cout<<data[i].count<< endl;
// по имени cout
}
}
//срок xранения через int + условие
return 0;
}