如图问题,谢谢
c++吧
全部回复
仅看楼主
level 5
i->empty为什么是错误的
2017年12月18日 08点12分 1
level 11
empty是方法还是变量 [汗]
2017年12月18日 09点12分 5
看图楼下
2017年12月18日 11点12分
level 11
你先想想empty到底是谁的成员
2017年12月18日 10点12分 6
书上不是和我一样吗,应该是vector<int>的成员吗?看一下下面的图,是书上的
2017年12月18日 11点12分
@浙江舟山007 书上大概不是vector<string>……
2017年12月18日 11点12分
@M_P_C_King 我把书上的完整的习题答案代码发一下。
2017年12月18日 12点12分
@浙江舟山007 所以你现在知道了没,书上到底是不是vector<string>?
2017年12月18日 14点12分
level 5
2017年12月18日 11点12分 7
这里text大概是std::vector<std::string>之类的吧
2017年12月18日 11点12分
level 9
少了个括号[汗][滑稽]
2017年12月18日 12点12分 8
level 5
#include<iostream>
#include<string>
#include<vector>
#include<cstdlib>
using namespace std;
int main()
{
vector<string>text;
string s;
while (getline(cin,s))
text.push_back(s);
for (auto it=text.begin();it!= text.end() && !it->empty(); it++)
{
for (auto it2 = it->begin(); it2 != it->end(); it2++)
*it2 = toupper(*it2);
cout << *it << endl;
}
system("PAUSE");
return 0;
}
这样的代码就能运行,难道缺少了()括号吗?
2017年12月18日 12点12分 9
level 9
你先想想你要表达什么逻辑[汗]
2017年12月18日 12点12分 10
level 9
看不出这个empty判断有什么存在的必要[汗]
2017年12月18日 12点12分 11
就是确保不是空字符串
2017年12月18日 12点12分
然而你写的是int并不是字符串[汗]
2017年12月18日 17点12分
@VX186743879 OK,谢谢。
2017年12月19日 00点12分
1