Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct zakaz{
- int number;
- string FIO;
- string tovar;
- int cnt;
- int sum;
- };
- int main()
- {
- int n;
- cin >> n;
- zakaz a[n];
- for (int i = 0; i < n; i++){
- cin >> a[i].number >> a[i].FIO >> a[i].tovar;
- cin >> a[i].cnt >> a[i].sum;
- }
- // сортировка
- for (int i = 0; i < n; i++){
- for (int j = 0; j < n - 1; j++){
- if (a[j].number > a[j + 1].number){
- zakaz temp;
- temp = a[j];
- a[j] = a[j + 1];
- a[j + 1] = temp;
- }
- }
- }
- int num;
- cin >> num;
- int l = 0, r = n - 1;
- while (r - l > 1){
- int i = (r + l) / 2;
- if (a[i].number >= num){
- r = i;
- }else {
- l = i;
- }
- }
- if (a[l].number == num){
- cout << a[l].number << " " << a[l].FIO;
- }else{
- cout << a[r].number << " " << a[r].FIO;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement