Answer the question
In order to leave comments, you need to log in
How to translate this c++ code to python?
How to translate this c++ code to python?
#include <iostream>
using namespace std;
int main(void)
{
long k, m, n, res; // косметологов, часов у каждого, девушек
cin>>k>>m>>n;
res=n/k*2*m;
if(n%k) res+=2*m;
cout<<res;
return 0;
}
Answer the question
In order to leave comments, you need to log in
import sys
if __name__ == "__main__":
k, m, n = map(int, input().split())
res = n / k * 2 * m
if n % k: res += 2 * m
print(res)
sys.exit(0)
I'm also having trouble translating python code.
I'll be praying for you!))))
Here's the code:
#include
#include
#define DEVICE_ID 0x08
int main (int argc, char **argv)
{
// Setup I2C communication
int fd = wiringPiI2CSetup(DEVICE_ID);
if (fd == -1) {
std::cout << "Failed to init I2C communication.\n";
return -1;
}
std::cout << "I2C communication successfully setup.\n";
// Send data to arduino
uint8_t data_to_send = 17;
wiringPiI2CWrite(fd, data_to_send);
std::cout << "Sent data: " << (int)data_to_send << "\n";
int received_data = wiringPiI2CRead(fd);
std::cout << "Data received: " << received_data << "\n";
if (received_data == data_to_send) {
std::cout << "Success!\n";
}
return 0;
}
Pairing program for I2C Disassemble and Arduino
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question