#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct river{
string name;
double length;
double depth;
bool ships;
};
signed main(){
int n;
cin >> n;
river a[n];
for(int i = 0; i < n; i++)
cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;
vector<river> ans;
for(auto i: a)
if(i.length > 2 && i.ships)
ans.push_back(i);
for(auto i: ans){
cout << "name: " << i.name << "\n";
cout << "length: " << i.length << "\n";
cout << "depth: " << i.depth << "\n";
cout << "ships?: Yes";
}
import random
class Passanger:
def __init__(self, name_pass, bagadge_value, bagadge_quantity):
"""Constructor"""
self.name_pass = name_pass
self.bagadge_value = bagadge_value
self.bagadge_quantity = bagadge_quantity
if __name__ == "__main__":
list_name_pass = ["Иванов","Иванова","Калдыбег","Мухутдинов","Карелов","Анакондов"]
list_bagadge_value = [25,1,4,14,29,35,2,4,25,6,25,3]
list_bagadge_quantity = [1,4,5,1,1,1,1,1,1,4]
list_passangers = []
random.shuffle(list_name_pass)
random.shuffle(list_bagadge_value)
random.shuffle(list_bagadge_quantity)
for i in range(len(list_name_pass)):
list_passangers.append(Passanger(list_name_pass[i],list_bagadge_value[i], list_bagadge_quantity[i]))
print("Подходят под условие:")
for i in list_passangers:
if (i.bagadge_value < 25 and i.bagadge_quantity == 1):
print(i.name_pass, i.bagadge_value, i.bagadge_quantity)
print("")
print("Пассажиры:")
Объяснение:
https://pastebin.com/hNT2m49y
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct river{
string name;
double length;
double depth;
bool ships;
};
signed main(){
int n;
cin >> n;
river a[n];
for(int i = 0; i < n; i++)
cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;
vector<river> ans;
for(auto i: a)
if(i.length > 2 && i.ships)
ans.push_back(i);
for(auto i: ans){
cout << "name: " << i.name << "\n";
cout << "length: " << i.length << "\n";
cout << "depth: " << i.depth << "\n";
cout << "ships?: Yes";
}
}
import random
class Passanger:
def __init__(self, name_pass, bagadge_value, bagadge_quantity):
"""Constructor"""
self.name_pass = name_pass
self.bagadge_value = bagadge_value
self.bagadge_quantity = bagadge_quantity
if __name__ == "__main__":
list_name_pass = ["Иванов","Иванова","Калдыбег","Мухутдинов","Карелов","Анакондов"]
list_bagadge_value = [25,1,4,14,29,35,2,4,25,6,25,3]
list_bagadge_quantity = [1,4,5,1,1,1,1,1,1,4]
list_passangers = []
random.shuffle(list_name_pass)
random.shuffle(list_bagadge_value)
random.shuffle(list_bagadge_quantity)
for i in range(len(list_name_pass)):
list_passangers.append(Passanger(list_name_pass[i],list_bagadge_value[i], list_bagadge_quantity[i]))
print("Подходят под условие:")
for i in list_passangers:
if (i.bagadge_value < 25 and i.bagadge_quantity == 1):
print(i.name_pass, i.bagadge_value, i.bagadge_quantity)
print("")
print("Пассажиры:")
for i in list_passangers:
print(i.name_pass, i.bagadge_value, i.bagadge_quantity)
Объяснение:
https://pastebin.com/hNT2m49y