当我采用测试用例数 = 1 时,我的程序终止.其他明智的是,它给出了正确的答案,但跳过了最后一个测试用例
My program terminates when I take number of test case =1. Other wise, it gives correct answer but skips the last testcase
我正在尝试从Google codejam 2010中解决这个 https://code.google.com/codejam/contest/351101/dashboard#s=p1 练习问题,这是我的解决方案。http://ideone.com/j8Q8f5
getline(cin,s);
我在使用 getline 函数时遇到问题。我的代码有什么问题。
这是因为在读取测试用例数量后,您的输入流仍然在同一行上。因此,您调用的第一个getline
将始终返回一个空字符串(第一行的其余部分包含测试用例的数量)。
只需添加
string dummy;
getline(cin, dummy);
扫描后立即t
:http://ideone.com/bunejC
相关文章:
- 如何使用重载的相等(==)运算符向测试用例添加描述
- 从父数组测试用例构造二叉树失败
- 在Raspbian上编译pybind11测试用例时出现致命错误
- 我遇到了黑客排名中的问题"TWO STRINGS"的三个测试用例的分段错误。原因是什么?
- 某些测试用例未通过
- 如何在多个 Catch2 测试用例中检查相同的条件
- 谷歌启动2018,测试用例中的整数错误
- 用于查找连续子数组的最大总和的代码使测试用例失败
- 查找不适用于 c++ 中特定测试用例的最长子字符串
- 测试用例状态为失败,但返回的值为 true
- kill syscommand 在 Catch2 测试用例中失败
- 大型测试用例中C++ dfs 问题中的小错误
- 为什么在输入的第一行输入测试用例数量后得到垃圾值?
- C++ Catch 是否有类似 NUnit 的测试用例的东西,具有多个参数/输入选项
- 如何修复此代码对几个测试用例的错误答案?
- 所有测试用例都将小数点转换为二进制数
- C++回文检查解决方案被一个测试用例跳闸
- 测试用例大小为 10 的向量失败
- 将 argc 和 argv 传递给 QApplication 到单元测试用例方法中
- 我提交了解决方案,并在第 4 个测试用例中出现时间限制错误