Mantiq amallari
Yuqoridagi misolning C++ dasturlash tilida kodi:
#include
bool calculateExpression(bool a, bool b, bool c) {
bool result = ((!a || !(b && !c)) && b && c) || ((!a && (b && !c)) && !c);
return result;
}
int main() {
bool a = true;
bool b = true;
bool c = false;
bool finalResult = calculateExpression(a, b, c);
std::cout << "Result: " << std::boolalpha << finalResult << std::endl;
return 0;
}
Yuqoridagi misolning python dasturlash tilida kodi:
def calculate_expression(a, b, c):
result = (not (a or (b and not c))) and b and c or (not (a and (b and not c))) and not c
return result
a = True
b = True
c = False
final_result = calculate_expression(a, b, c)
print("Result:", final_result)
Do'stlaringiz bilan baham: |