Первое задание:
1) 3
2) 6
3) 5
Второе задание:
1) 1
2) 3
Третие:
//Язык программирования java
package com.niksonbinsk;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int space_left = 0;
int count = 0;
Scanner s = new Scanner(System.in);
ArrayList<Integer> str = new ArrayList<>();
while(space_left != 30){
System.out.println("Enter next num:");
str.add(s.nextInt());
space_left++;
}
for(int i =0;i<30;i++){
if(str.get(i) % 2 == 0){
count++;
System.out.println(count);
Объяснение:
Вопрос скорее будет звучать "как много могли съесть толстяки?".
#include <iostream>
using namespace std;
int main() {
int multiplier = 1;
float weightCake = 0;
float t1(0), t2(0), t3(0);
float t1Cakes(0), t2Cakes(0), t3Cakes(0);
cout << "Weight of cake, fat people 1-3: ";
cin >> weightCake; cin >> t1; cin >> t2; cin >> t3;
while(1) {
t1Cakes = multiplier * weightCake * 1;
if(t1Cakes > t1/2) {
cout << multiplier - 1;
break;
t2Cakes = multiplier * weightCake * 2;
if(t2Cakes > t2/2) {
t3Cakes = multiplier * weightCake * 4;
if(t3Cakes > t3/2) {
++multiplier;
Первое задание:
1) 3
2) 6
3) 5
Второе задание:
1) 1
2) 3
Третие:
//Язык программирования java
package com.niksonbinsk;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int space_left = 0;
int count = 0;
Scanner s = new Scanner(System.in);
ArrayList<Integer> str = new ArrayList<>();
while(space_left != 30){
System.out.println("Enter next num:");
str.add(s.nextInt());
space_left++;
}
for(int i =0;i<30;i++){
if(str.get(i) % 2 == 0){
count++;
}
}
System.out.println(count);
}
}
Объяснение:
Вопрос скорее будет звучать "как много могли съесть толстяки?".
#include <iostream>
using namespace std;
int main() {
int multiplier = 1;
float weightCake = 0;
float t1(0), t2(0), t3(0);
float t1Cakes(0), t2Cakes(0), t3Cakes(0);
cout << "Weight of cake, fat people 1-3: ";
cin >> weightCake; cin >> t1; cin >> t2; cin >> t3;
while(1) {
t1Cakes = multiplier * weightCake * 1;
if(t1Cakes > t1/2) {
cout << multiplier - 1;
break;
}
t2Cakes = multiplier * weightCake * 2;
if(t2Cakes > t2/2) {
cout << multiplier - 1;
break;
}
t3Cakes = multiplier * weightCake * 4;
if(t3Cakes > t3/2) {
cout << multiplier - 1;
break;
}
++multiplier;
}
}