728x90
반응형
mstmatch
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void main()
{
int ari[]={8,9,0,6,2,9,9};
vector<int> vi(&ari[0],&ari[7]);
vi[3]=7;
pair<int *,vector<int>::iterator> p;
p=mismatch(&ari[0],&ari[7],vi.begin());
if (p.first != &ari[7]) {
printf("%d번째 자리(%d,%d)부터 다르다.\n",
p.first-ari,*(p.first),*(p.second));
} else {
puts("두 컨테이너가 일치한다.");
}
}
mstmatch2
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void main()
{
int answer[]={1,1,4,3,2,4,3,2,3,4,1,2,4,4,3,2,1,3,2,4};
int paper[]= {1,1,4,3,3,4,3,1,3,4,1,2,4,4,3,4,1,3,2,2};
pair<int *,int *> p;
int i;
for (i=0;;) {
p=mismatch(&answer[i],&answer[20],&paper[i]);
if (p.first == &answer[20]) break;
printf("%d번 틀림, 정답=%d, 니가 쓴 답=%d\n",
p.first-answer+1,*(p.first),*(p.second));
i=p.first-answer+1;
}
}
728x90
반응형
댓글