带有输入流的在线 C++ 编译器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7894930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Online C++ compiler with input stream?
提问by Xorty
I kinda like codepad online editor (supports C++), but I'd like to use some scanfs which is not possible with codepad.
我有点喜欢codepad 在线编辑器(支持 C++),但我想使用一些scanfs,这在codepad中是不可能的。
Is there some online C++ compiler that supports input streams? Is that even possible?
是否有一些支持输入流的在线 C++ 编译器?这甚至可能吗?
采纳答案by Jon
回答by sehe
[ Disclaimer: I prefer ideone.com (has c++0x support as well)]
[免责声明:我更喜欢ideone.com(也有c++0x支持)]
Getting very pedantic, you could stuff your input inside the source file by playing this dirty trick:
变得非常迂腐,你可以通过玩这个肮脏的把戏来把你的输入塞进源文件中:
/* just skip the first two (!!!) lines when reading from t.cpp
602.030024387
423.927317911
520.43881927
131.655014874
35.7455352247
548.735653436
714.556123804
876.948673754
379.105540406
885.096900058
192.734103705
116.365922766
363.998415895
216.268387112
958.684513705
*/ // end of fake input
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
std::ifstream ifs("t.cpp");
std::cout << ifs.rdbuf() << std::flush;
}
回答by Shafik Yaghmour
Rextester
has an input box as well and has a more usable interface than ideone
which I have always felt was very clunky.
Rextester
也有一个输入框,并且有一个比ideone
我一直觉得非常笨重的更有用的界面。
Coliru
allows you to use multiple files, so you can create an file with your data and do something like this to input into your program:
Coliru
允许您使用多个文件,因此您可以使用您的数据创建一个文件并执行以下操作以输入到您的程序中:
g++ -std=c++11 -W -Wall main.cpp && cat /Archive/{{id}}/main.cpp | a.out
Note, LWS
also has a nice interface and an input box but has been in read-only
mode for a while now and it is not clear it is coming back online anytime soon if at all.
请注意,它LWS
还有一个不错的界面和一个输入框,但现在已经处于read-only
模式中了一段时间,目前尚不清楚它是否会很快重新上线(如果有的话)。
回答by gmfreak
You can try http://optimizedbits.com. There you can also compile your code by providing your own stream of multiple inputs.
你可以试试http://optimizedbits.com。在那里,您还可以通过提供您自己的多个输入流来编译您的代码。
For just one input stream, simply write the input. For multiple input test cases, follow:
对于只有一个输入流,只需编写输入。对于多输入测试用例,请遵循:
input1
<TESTCASE>
input2
<TESTCASE>
....
Regarding the possibility of input stream: See no body builds a compiler on their own. Everybody utilizes some standards like gcc in the back-end. All online compiler websites work around a architecture which involves the following flow(example:C++):
关于输入流的可能性:看到没有机构自己构建编译器。每个人都在后端使用一些标准,如 gcc。所有在线编译器网站都围绕涉及以下流程的架构工作(示例:C++):
1) read_code_user
2) Save it as variablename.cpp
3) Use a queuing framework. Then execute g++ variablename.cpp. Further, various libraries are utilized which can pipe stdin, stdout and stderr.
回答by user3747740
try http://compileonline.com/enter your input in STDIN
尝试http://compileonline.com/在 STDIN 中输入您的输入