Created
October 31, 2020 22:41
-
-
Save rebornplusplus/aeec12b641403d8e8a4e4305738b7bcc to your computer and use it in GitHub Desktop.
Interactive stuffs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
void read(int& x, int& y) { | |
cin >> x >> y; | |
cerr << "cc< " << x << " " << y << endl; | |
} | |
void write(int x, int y) { | |
cout << x << " " << y << endl; | |
cerr << "cc> " << x << " " << y << endl; | |
} | |
int main(int argc, char** argv) { | |
int x = 2, y = 4; | |
while(x < 10) { | |
write(x, y); | |
read(x, y); | |
++x; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
def read(): | |
x, y = map(int, input().split()) | |
sys.stderr.write("py< {} {}\n".format(x, y)) | |
sys.stderr.flush() | |
return [ x, y ] | |
def write(x, y): | |
print("{} {}".format(x, y)) | |
sys.stdout.flush() | |
sys.stderr.write("py> {} {}\n".format(x, y)) | |
sys.stderr.flush() | |
while True: | |
x, y = read() | |
y += 1 | |
write(x, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -o cpp cpp.cc | |
mkfifo fifo | |
# ./cpp <fifo | tee >(./py.py | tee fifo) | |
./cpp <fifo | ./py.py >fifo | |
rm fifo cpp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment