-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvect3.cpp
More file actions
39 lines (31 loc) · 1.04 KB
/
Copy pathvect3.cpp
File metadata and controls
39 lines (31 loc) · 1.04 KB
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
//
// Created by 赵健 on 2021/8/17.
//
#include "vect3.h"
void vect3::test() {
using namespace std;
vector<Review> books;
Review temp;
while(FillReview(temp)) books.push_back(temp);
if(!books.empty()) {
cout << "Thank you. You entered the following "
<< books.size() << " rating:\n"
<< "Rating\tBook\n";
for_each(books.begin(), books.end(), ShowReview);
sort(books.begin(), books.end());
cout << "Sorted by title:\nRating\tBook\n";
for_each(books.begin(), books.end(), ShowReview);
sort(books.begin(), books.end(), worseThan);
cout << "Sorted by rating:\nRating\tBook\n";
for_each(books.begin(), books.end(), ShowReview);
random_shuffle(books.begin(), books.end());
cout << "After shuffling:\nRating\tBook\n";
for_each(books.begin(), books.end(), ShowReview);
}
}
double * find_ar(double * ar, int n, const double & val){
for (int i = 0; i < n; i++) {
if(ar[i] == val) return &ar[i];
}
return 0;
}