{{{~cpp #include // 랜덤함수는 iostream에 포함되어 있습니다. #include using namespace std; int main() { srand(time(0)); // rand()의 시드값을 설정합니다. // 하지 않으면 실행할때마다 같은값을 만듭니다. -_-;; int base = rand() % 1000; // % 9를 하면 0~9까지의 숫자가 들어갈 수 있고 // 거기에 1을 더하면 1~10 까지의 숫자가 됩니다. int a,b,c,d,e,f; int S=0,B=0,O=0; cout << base << "\n"; a = base/100; b = (base%100)/10; c = (base%100)%10; int input; cout << "세자리의 수를 입력 하세요.\n"; cin >> input; d = input/100; e = (input%100)/10; f = (input%100)%10; int abc[3]={a, b, c}; int def[3]={d, e, f}; int i,j; while(a!=def[0] || b!=def[1] || c!=def[2]) { for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(abc[i]==def[j]) { if(i==j) S++; else B++; } } } if(S==0 && B==0) cout << "Out\n"; else if(S==3) { cout << " 맞추셨습니다.\n" ; break; } else cout << S <<" S " << B <<" B " <> input; def[0] = input/100; def[1] = (input%100)/10; def[2] = (input%100)%10; } return 0; } }}}