구
~cpp #include<iostream> // 랜덤는 iostream 되 다. #include <ctime> // time(0) 다. using namespace std; void main() { // srand(time(0)); // rand() 드값 다. // 면 때다 같값 만듭다. -_-;; // int x = rand(); // rand()는 랜덤 를 리는 다. // 리는 범는 0 ~ 무무 다. // int x1 = rand() % 10; // % 10 면 x1 는 10 나머가 될 는 // 0 ~ 9 까 가 랜덤게 들갑다. // int x2 = rand() % 9 + 1; // % 9를 면 0~9까 가 들 고 // 기 1 더면 1~10 까 가 됩다. cout << "리 를 력 : " << endl; srand(time(0)); int x; int a[3]; do { x = rand() % 1000; a[0] = x/100; a[1] = (x-(a[0]*100))/10; a[2] = (x-(a[0]*100)-(a[1]*10))/1; }while(a[0]==a[1]||a[1]==a[2]||a[0]==a[2]); cout << a[0]<<a[1]<<a[2] << endl; int soo; do { cin >> soo; int c[3]; c[0] = soo/100; c[1] = (soo-(c[0]*100))/10; c[2] = (soo-(c[0]*100)-(c[1]*10))/1; int i; int count =0; int count2=0; for(i=0; i<3; i++) { if (a[i] == c[i]) count++ ; } cout << count << " strike"<<"\t"; if (a[0]==c[1]) count2++; if (a[0]==c[2]) count2++; if (a[1]==c[0]) count2++; if (a[1]==c[2]) count2++; if (a[2]==c[0]) count2++; if (a[2]==c[1]) count2++; cout << count2 << " ball" << endl; if (count == 3) { cout << " !!"<<endl; cout << "다 ~!!"<< endl; } }while (soo!=x); }