Подключить надо
Добавлено через 7 минут
Вот так: еще string надо включить
C++ |
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
| #include <iostream>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
struct noteboo
{
string mark;
int cen;
};
int main()
{
setlocale(LC_ALL,"Russian");
vector<noteboo> notebook;
noteboo k;
k.cen=1;
int ce=0;
int p=0;
while(k.cen!=0)
{
cout << "Чтобы выйти введите цену 0: " <<endl;
cout << "Введите цену ноутбука: ";
cin >> k.cen;
if(k.cen==0)break;
cout << "Введите марку ноутбука: ";
cin >> k.mark;
notebook.push_back(k);
}
cout << "Ввведите искомую цену ноутбука: ";
cin >> ce;
int j=0;
int l=1000000;
for(int i=0;i<notebook.size();i++)
{
if(abs(ce-notebook[i].cen)<l)
{
l=notebook[i].cen;
j=i;
}
}
cout << "Самый лучший вариант это: " << notebook[j].mark <<" Стоимость которого:"<< notebook[j].cen<<endl;
cin.get();
return 0;
} |
|