1.
a, b = map(int, input('Введите a, b: ').split())
lst = [[int(_) for _ in input('Введите элементы: ').split()] for j in range(int(input('Введите число строк: ')))]
count = 0
for i in range(len(lst[0])):
for j in range(len(lst)):
if lst[j][i] % a == 0 or lst[j][i] % b == 0:
count += 1
print(f'{i + 1}: {count}')
count = 0
2.
lst = [[int(_) for _ in input('Элементы: ').split()] for p in range(int(input('Введите число строк: ')))]
a = input('Введите а: ')
positive = False
num = False
for i in range(len(lst)):
print(f'{i + 1}: ', end='')
for j in lst[i]:
if j > 0:
positive = True
if str(j)[-1] == a:
num = True
if positive:
print('Положительные элементы есть', end='; ')
else:
print('Положительных элементов нет', end='; ')
print(('Есть элементы, ' if num else 'Нет элементов, ') + 'последняя цифра которых = a')
num = False
positive = False
3.
num = int(input('Введите число: '))
print(f'a) {num % 2 == 0}')
print(f'b) {str(num)[-1] == "7"}')
print(f'c) {num % 2 == 0}')
- DrinkActivity.java
TextView t ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drink);
t = (TextView)findViewById(R.id.TextView01);
t.setOnClickListener((android.view.View.OnClickListener) this);
}
public void onClick(View arg0) {
t.setText("My text on click");
}
- activity_drink.xml
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
<ListView
android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</ListView>
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
<TextView android:text="This is my first text"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:textStyle="bold"
android:textSize="28sp"
android:editable="true"
android:clickable="true"
android:layout_height="wrap_content"
android:onClick="onClick">
</TextView>
Объяснение:
первый
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Введите количество часов: ";
cin >> n;
int амебы = 1;
int часы = 0;
while (часы <= n) {
cout << "Через " << часы << " часов: " << амебы << " амеб" << endl;
амебы *= 2;
часы += 3;
}
return 0;
}
второй
#include <iostream>
using namespace std;
int main() {
int N;
cout << "Введите число N: ";
cin >> N;
cout << (N + 2) - (N % 2) << endl;
return 0;
}
третий
#include <iostream>
using namespace std;
int main() {
int A, B, N;
cout << "Введите стоимость пирожка в рублях: ";
cin >> A;
cout << "Введите стоимость пирожка в копейках: ";
cin >> B;
cout << "Введите количество пирожков: ";
cin >> N;
int total = (A * 100 + B) * N;
cout << "Стоимость " << N << " пирожков: " << total / 100 << " рублей и " << total % 100 << " копеек" << endl;
return 0;
}
четвертый
#include <iostream>
using namespace std;
int main() {
int N;
cout << "Введите количество минут: ";
cin >> N;
int hours = (N / 60) % 24;
int minutes = N % 60;
cout << "Электронные часы показывают: " << hours << " часов и " << minutes << " минут" << endl;
return 0;
}
пятый
#include <iostream>
using namespace std;
int main() {
int N;
cout << "Введите трехзначное число: ";
cin >> N;
int sum = 0;
sum += N % 10;
N /= 10;
sum += N % 10;
N /= 10;
sum += N % 10;
cout << "Сумма цифр: " << sum << endl;
return 0;
}