【发布时间】:2020-03-10 01:06:42
【问题描述】:
输入: [1-st string]狗
[2-nd string]我爱狗
[3-rd string]狗爱我
[第4串]爱
输出: [1-st string]狗
[第二串]爱
我如何在 c++ 中做这样的事情?>不使用 vector.Thx :)
【问题讨论】:
-
您的问题描述是什么?
标签: c++ arrays string file iostream
输入: [1-st string]狗
[2-nd string]我爱狗
[3-rd string]狗爱我
[第4串]爱
输出: [1-st string]狗
[第二串]爱
我如何在 c++ 中做这样的事情?>不使用 vector.Thx :)
【问题讨论】:
标签: c++ arrays string file iostream
您有一个格式为“B 类中没有 A”的问题。此类问题的算法是
bool wrong = false;
while ( /* there is another A */ )
{
if ( /* check if it is NOT within a class */ )
{
wrong=true;
break;
}
}
if (wrong)
{
// here you know that at least one thing was NOT within a class B
}
else
{
// here you know that every item A was within a class B
}
在您的情况下,“类”是“没有空格的字符串”,要检查是否有空格,您只需使用 this condition。
【讨论】: