Скопировать код в Dev C++ и запустить в компиляторном окне будут выведены значения.
Объяснение:
Dev C++
1) #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int x = 5, y = 10;
while(y<=10){
if (x <= y){
x = x + 1;
y = y - 1;
}
else {
x = x - 5;
y = y + 5;
}
}
printf("X = %d", x);
printf("\nY = %d", y);
return 0;
}
2) #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int a = 2, b = 0;
while (a != 7){
a = a + 1;
b = b + a;
}
printf("a = %d", a);
printf("\nb = %d", b);
return 0;
}
3) #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int a = 56, b = 77;
while (a != b){
if (a > b){
a = a - b;
}
else {
b = b - a;
}
}
printf("a = %d", a);
printf("\nb = %d", b);
return 0;
}
4) #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int a = 6, b = 0;
while (a!=2){
b = b + a;
a = a - 1;
}
printf("a = %d", a);
printf("\nb = %d", b);
return 0;
}
5) #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int a = 1, b = 0;
while (a != 1024){
b = b + a;
a = a * 2;
}
printf("a = %d", a);
printf("\nb = %d", b);
return 0;
}
class Finder:
def __init__(self):
self.current_range = range(1, 101)
def condition(self, user_select):
if user_select == '1':
return True
elif user_select == '2':
self.current_range = range(int(self.current_half + self.current_range.start), self.current_range.stop)
return False
elif user_select == '3':
self.current_range = range(self.current_range.start, int(self.current_half + self.current_range.start))
return False
@property
def current_half(self) -> int:
return int((self.current_range.stop - self.current_range.start) / 2)
finder = Finder()
while True:
user_select = input(f'Это {finder.current_half + finder.current_range.start}?\n')
result = finder.condition(user_select)
if result:
break