19
2011-04-20 20:53:35
0
#include "stdafx.h"
#include <algorithm>
#include <vector>
int _tmain(int argc, _TCHAR* argv[])
{
int nFixedNum;
int nRandomNum;
int nCorrectCase = 0;
std::vector<int> vctFixedNum;
std::vector<int>::iterator iter;
for(int i = 0; i < 6; i++)
{
printf("%d 번째 숫자를 입력하세요 ", i+1);
scanf("%d", &nFixedNum);
vctFixedNum.push_back(nFixedNum);
}
printf("무작위 숫자: ");
for(int i = 0; i < 6; i++)
{
nRandomNum = rand() % 21 + 1;
iter = std::find(vctFixedNum.begin(), vctFixedNum.end(), nRandomNum);
if(iter != vctFixedNum.end()) nCorrectCase++;
printf("%d ", nRandomNum);
}
printf("n총 %d번 일치 하였습니다.n", nCorrectCase);
return 0;
}