题目如下:
代码如下:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<int> a;
vector<int> b;
int s, v;
unsigned int small_size;
while (cin >> s)
{
a.push_back(s);
}
while (cin >> v)
{
b.push_back(v);
}
small_size = (a.size() >= b.size())? b.size() : a.size();
for (int i = 0;i<small_size; ++i)
{
if (a[i] != b[i])
{
cout << "f";
system("PAUSE");
}
}
cout << "t";
system("PAUSE");
}
我设想的是通过push_back依此初始化两个vector,但是发现这样不论输入正确与否结果t。如下:
但是如果我通过列表初始化,运行结果就是正常的。
自我感觉是因为用push_back初始化的时候出现了问题,但是不知道哪里的问题。
望各位解答,十分感谢!