gpt4 book ai didi

c++ - codeeval 部分正确

转载 作者:行者123 更新时间:2023-11-28 06:59:21 24 4
gpt4 key购买 nike

<分区>

这是我对 codeeval 解决方案的回答。显示部分正确。无法弄清楚为什么。

https://www.codeeval.com/open_challenges/18/这是个问题。很乐意提供帮助。

#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(int argc, char* argv[])
{
ifstream infile(argv[1]);

if(!infile.is_open())
{
cout << "Error:Cannot open file!";
cout << "Program terminating.\n";
exit(EXIT_FAILURE);
}

string line;
while(getline(infile, line, '\n'))
{
stringstream ss(line);
string token;

getline(ss,token,',');
long x = stoi(token);

getline(ss, token, ',');
long n = stoi(token);

while(n < x)
{
n <<= 1;
}
cout << n << "\n";
}
return 0;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com