![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Пользователь
Регистрация: 30.05.2010
Сообщений: 80
|
![]()
#include<iostream>
#include<iterator> #include<algorithm> #include<vector> #include<time.h> #include<fstream> #include<deque> #include<string> #include<typeinfo> #include<string.h> #include<conio.h> #include<iomanip> using namespace std; class PC { public: string name; int ram; int hdd; PC(); PC(string pr,int ram,int hdd); void Display() { cout<<setw(5)<<name<<setw(10)<<hdd< <" "<<ram<<" "<<endl; } bool cmp(string a,string b) { return(a<b); } }; PC::PC() { this->name="Core2Duo"; this->hdd=1000; this->ram=2048; } PC::PC(string pr,int ram,int hdd) { this->name=pr; this->hdd=hdd; this->ram=ram; } void Show(int a) { cout<<a<<endl; } void main() { ostream_iterator<int,char>out_it (cout," "); vector<PC> pc; vector<PC>::iterator it; pc.push_back(PC("Intel",2000,4096)) ; pc.push_back(PC("AMD",320,2048)); pc.push_back(PC("Apple",1000,4096)) ; pc.push_back(PC("I7",2000,32000)); pc.push_back(PC("Quad",640,2048)); cout<<pc.size()<<endl; sort(pc.begin(),pc.end(),it->cmp ); for(vector< PC >::iterator i = pc.begin(); i != pc.end(); i++ ) { i->Display(); } } не выходит реализация алгоритма сорт |
![]() |
![]() |
![]() |
#2 |
Пользователь
Регистрация: 22.04.2010
Сообщений: 96
|
![]()
Ты передаешь sort объкты PC, а в предикате пишешь типы string.
Код:
Код:
include <Qt>
|
![]() |
![]() |
![]() |
#3 |
Пользователь
Регистрация: 30.05.2010
Сообщений: 80
|
![]()
спасибо большое
|
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
STL флгоритм сорт | Progsenya | Общие вопросы C/C++ | 0 | 09.09.2010 22:13 |
Сортировка слиянием(1 сорт список+2 сорт список=3 сорт список) | Promolol | Помощь студентам | 0 | 21.05.2010 23:49 |
Сорт.дерево и пирамидальная сортировка | Санёк20 | Паскаль, Turbo Pascal, PascalABC.NET | 1 | 25.02.2008 18:22 |