users = [
'Anna',
'Bob',
'Veronika',
'Matthew',
'Lucas',
'Vladimir',
'Michael',
'Helena',
]
goods = [
['Apples', 70],
['Bananas', 30],
['Sugar', 45],
['Tea', 50],
['Coffee', 95],
['Ice cream',150],
]
name = input('what is your name: ')
print('Hello, ' + name)
something = input('What do you want to buy: ')
count = int(input('How many: '))
print('You want to buy ' + str(count) + ' ' + something)
for i in range(len(goods)):
if goods[i][0]==something: price=goods[i][1]
print(str(price))
total = price*count
print('It will cost you ' + str(total) + ' rouble(s)')
В задании указано сделать дружественную функцию для того чтобы устанавливать новую цену на книгу, но не указано делать поле price, поэтому я его добавил (с типом double).
Мой вариант:#include <iostream>
#include <string.h>
using namespace std;
class Book
{
char *autor;
char name[50];
int year;
double price;
public:
Book()
{
autor = new char[50];
strcpy(autor,"undefined");
strcpy(name,"undefined");
year=0;
price=0;
}
Book(char *name, char *autor, int year, double price)
{
this->autor = new char[50];
this->year=year;
strcpy(this->name,name);
strcpy(this->autor,autor);
this->price=price;
}
~Book()
{
delete[]autor;
}
char* getName() { return name; }
char* getAutor() { return autor; }
double getPrice() { return price; }
int getYear() { return year; }
friend void setPrice(Book& obj, double price);
friend void setYear(Book& obj, int year);
};
void setPrice(Book& obj, double price)
{
obj.price = price;
}
void setYear(Book& obj, int year)
{
obj.year = year;
}
int main()
{
Book b("Harry Potter","Joanne Rowling",1995,100);
cout << "Book name - " << b.getName() << endl;
cout << "Autor name - " << b.getAutor() << endl;
cout << "Release year - " << b.getYear() << endl;
cout << "Book price - " << b.getPrice() << endl;
setPrice(b,150);
setYear(b,1997);
cout << "New book price - " << b.getPrice() << endl;
cout << "New release year - " << b.getYear() << endl;
cin.get();
cin.get();
}
Поделитесь своими знаниями, ответьте на вопрос:
С ИНФОРМАТИКОЙ С ИНФОРМАТИКОЙ ">
ответ: 338
Объяснение:
1 круг - Магнитогорск
2 круг - Лицей
3 круг - Школа
N5 + N4 = 260
N4+ N5+ N6 = 467
N5 = 131
Следовательно:
N4 = 129
N6 = 207
N5 + N6 = 131 + 207 = 338