[英]How do I compare two arrays that are equal but one is in ascending order and other is in descending order?
[英]How do I store numbers in two arrays with specific order?
我想打开一个文本文件并完整阅读它,同时使用 c++ 将其内容存储到 arrays 中。 我在下面有我的示例文本文件。 我想将第一个数字存储到一个数组中,并将它们的 rest 逐行存储到第二个数组中。 例如 9 存储在第一个数组中,22 22 存储在第二个数组中,然后 1 存储在第一个数组中 2 3 4 在第二个数组中等等......我不确定如何在 c++ 中完成此操作,非常感谢任何帮助!
9 22 22
1 2 3 4
1 5
2 3 6 9
例如,当我打印第一个数组时,我想显示:9 1 1 2(第一列),当我打印第二个数组时,我想显示:22 22 2 3 4 等...
这是一种方法:
std::string
和std::getline
。std::istringstream
以简化提取。istringstream
中提取一个数字。arr1
。istringstream
并将它们放入arr2
中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.