C++ 如何在VisualStudio社区中设置类似于竞争性编程站点的环境?
我正试图在visual studio社区2017中创建类似在线竞争网站(Hackerearth.com、hackerrank.com和ideone.com)的环境,用于编码实践 检查这个C++ 如何在VisualStudio社区中设置类似于竞争性编程站点的环境?,c++,visual-studio,visual-studio-community,C++,Visual Studio,Visual Studio Community,我正试图在visual studio社区2017中创建类似在线竞争网站(Hackerearth.com、hackerrank.com和ideone.com)的环境,用于编码实践 检查这个 是竞争编程中C++代码中大多数问题的标准结构。 #include <iostream> #include <string> using namespace std; int main() { int t; cin >> t; string s;
是竞争编程中C++代码中大多数问题的标准结构。
#include <iostream>
#include <string>
using namespace std;
int main()
{
int t;
cin >> t;
string s;
while (t--) {
cin >> s;
cout << " Hello " << s << "\n";
cin.get();
}
}
input:
5
Sam
Kiara
Victor
Riley
Diva
output:
Hello Sam
Hello Kiara
Hello Victor
Hello Riley
Hello Diva
我知道我可以使用文件系统,但当我必须将代码从本地系统上传到在线编辑器时,我必须更改代码以匹配这些站点的环境。我想在本地创建相同的环境,这样我就不必每次在站点上提交时都更改代码 添加
input.txt
对项目和
试试这个
intmain(intargc,char*argv[]){
尝试
{
#ifdef硕士学位
#pragma警告(推送)
#pragma警告(禁用:4996)//4996用于_CRT_SECURE_NO_警告等效
freopen(“intput.txt”,“r”,stdin);
#布拉格警告(pop)
#恩迪夫
int n;//车间数量
cin>>n;
}
捕获(…){
难道这些都不是错误。只是告诉你没有PDB
文件,你的调试会话无法加载源代码。我对visual studio非常陌生。除了这些,我没有得到任何输出。那么你有什么问题吗?只要在你的程序中读取文件并输出到文件中,为什么你会让这变得如此复杂?像这样freopen(“input.txt”,“r”,stdin);
对吗?我可以在Visual studio中使用它,但在线编辑器不允许使用它。(可能我错了,我不知道如何使用它).正如我提到的,每次在在线编辑器上提交代码时,我都必须更改此代码。我希望您得到我真正想要的。如果您给出一个示例,将非常有帮助。
'FirstProject.exe' (Win32): Loaded 'F:\Visual Studio\FirstProject\Debug\FirstProject.exe'. Symbols loaded.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'FirstProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
The program '[3764] FirstProject.exe' has exited with code 0 (0x0).
int main(int argc, char *argv[]) {
try
{
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4996) //4996 for _CRT_SECURE_NO_WARNINGS equivalent
freopen("intput.txt", "r", stdin);
#pragma warning(pop)
#endif
int n; // number of workshops
cin >> n;
}
catch (...) {
cout << "Error" << endl;
}
#ifdef _MSC_VER
fclose(stdin);
#endif
return 0;
}