哪位可否介绍一下difference_type和 mismatch??

cd7809 2003-07-24 04:47:38

最好举个小例子,非常感谢!
...全文
22 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fangrk 2003-07-24
  • 打赏
  • 举报
回复
Member Where defined Description
difference_type Container A signed integral type.


Distance type
X::difference_type
A signed integral type used to represent the distance between two of the container's iterators. This type must be the same as the iterator's distance type.
fangrk 2003-07-24
  • 打赏
  • 举报
回复
int A1[] = { 3, 1, 4, 1, 5, 9, 3 };
int A2[] = { 3, 1, 4, 2, 8, 5, 7 };
const int N = sizeof(A1) / sizeof(int);

pair<int*, int*> result = mismatch(A1, A1 + N, A2);
cout << "The first mismatch is in position " << result.first - A1 << endl;
cout << "Values are: " << *(result.first) << ", " << *(result.second) << endl;

24,855

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧