C++primer习题6.16

来源:转载

比较包含关系:

#include <iostream>#include<vector>#include<string>using namespace std;bool my(vector<int> a, vector<int> b, size_t size){ for (size_t i = 0; i < size; ++i) { if(a[i] != b[i]) return false; } return true;}int main(){ vector<int> a,b; int c = 0; cout << "input a: "; while (cin >>c) a.push_back(c); cin.clear(); //cin.ignore(); cout << "input b: "; while (cin >> c) b.push_back(c); size_t size_a = a.size(), size_b = b.size(); size_t i = 0; bool re = size_a>size_b ? my(a,b,size_b):my(a,b,size_a); cout << boolalpha << re << endl; }


分享给朋友:
您可能感兴趣的文章:
随机阅读: