2. ¶
~cpp #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; int main() { int num[3]; while(num[0]==num[1] || num[1]==num[2] || num[0]==num[2]) { srand(time(NULL)); for(int i=0; i<3; i++) num[i] = rand()%9 +1; } cout <<" 각 : " << num[0] << num[1] << num[2] << "\n"; int ch; while(ch) // X {cout <<" : "; cin >> ch; int person[3]; int bcount=0; int scount=0; person[0] = ch/100; person[1] = (ch%100)/10; person[2] = (ch%10); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { if(num[i]==person[j]) { if(i==j) scount++; else bcount++; } } } if(scount==0 && bcount==0) cout << " : OUT\n"; else if(scount==0 && bcount!=0) cout << " : "<< bcount << "\n"; else if(bcount==0 && scount!=0) { cout << " : " << scount << "\n"; if(scount==3) break; } else cout << " : "<< scount << " " << bcount << "\n"; } cout << "그 .\n"; return 0; }
.. -_-+
길~ while 고 깔게 까.?
길~ while 고 깔게 까.?
- ,, ~ ㅋㅋ -
- -_-;;; - 균
- 값 .ㅋㅋ
- 값 .ㅋㅋ
3. 권 ¶
~cpp // 게. 간 기 게 4 9 . #include <iostream.h> #include <stdlib.h> #include <time.h> int main() { int rand_num[3]; // . int i, j, k, num; //i,j,k , num . int player_num[3]; // 값 각 rand_num과 교기 게 . int ext,extra; // . int strike, ball; // . srand(time(NULL)); for(i=0;i<3;i++){ rand_num[i] = rand()%10; // . if (i == 1 && rand_num[i] == rand_num[0]) i--; else if (i == 2 && (rand_num[i] == rand_num[0] || rand_num[i] == rand_num[1])) i--; } // if 4 게 게 . for (i=0;i<9;i++){ //게 cout << "3 ( 겹 게 ) : " ; cin >> num; ext = num; if (num < 100 || num > 999) { cout << "\a . . \n"; i--; } else{ for (j=2;j>=0;j--){// 꾸 player_num[j] = ext%10; ext = ext/10; } for(j=0;j<2;j++){ //각 교 extra = 1; for(k=j+1;k<3;k++){ if (player_num[j] == player_num[k]) { cout << "\a . . \n"; i--; extra = 0; break; } if (extra == 0) break; } if (extra == 0) break; } // 각 교 } // else if (extra == 0) continue; strike = 0; ball = 0; if (extra == 1) { for(j=0;j<3;j++){ for(k=0;k<3;k++){ if (rand_num[j] == player_num[k] && j==k) strike++; if (rand_num[j] == player_num[k] && j!=k) ball++; } } } if (strike == 0 && ball == 0) cout << ".\n"; else cout << strike << ", " << ball << " .\n"; if (strike == 3) { cout << " .!!\n"; break; } if (i==8 && strike!=3) cout << "9 게 .\n"; } // 게 return 0; }
고 길 -_-;;; -
- .. 그고 갑기 깨 ..
게 겠 ㅜㅜ -
4. ¶
~cpp #include<iostream> // ^^ #include<ctime> using namespace std; int main() { int num[3]; int yagu[3]; int a; cout<<" 각 :"; srand(time(NULL)); do { for(int i=0;i<3;i++) num[i]=rand()%9+1; }while(!(num[0]!=num[1] && num[1]!=num[2] && num[2]!=num[0])); cout<<num[0]<<num[1]<<num[2]; up : cout<<"\n:"; cin>>a; if(a<1000 && a>99) { yagu[0]=a/100; yagu[1]=(a-yagu[0]*100)/10; yagu[2]=(a-yagu[0]*100-yagu[1]*10); } else cout<<" :"; int strike=0; int ball=0; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { if(yagu[i]==num[j]) { if(i==j) strike++; if(i!=j) ball++; } } } if(strike!=0 && ball==0) if(strike==3) cout<<strike<<"! "; else {cout<<strike<<""; goto up; } else if(strike==0 && ball!=0) { cout<<ball<<""; goto up; } else if(strike!=0 && ball!=0) { cout<<strike<<""<<ball<<""; goto up; } else { cout<<"out"; goto up; } return 0; }
- goto 각 ... ... 간 교 goto 게 고 .. ㅡㅜ 고 거 게 ?? 그 게 게 계 고 .. 길.... -
- 100% 고 100% . dijkstra goto 고 각 고 . ? ? 그 결 기까 과. SeeAlso NotToolsButConcepts고 Goto Statements Considered Harmful 구 결과
GotoConsideredHarmful -
- ~ ~ ~ -
- ...goto...거 =ㅅ= - 균
- goto 2003 4 goto (?) 기 . 2003 GotoConsideredHarmful 고 기. Dijkstra 각 겁. --개
- go to 게 군. .. -
5. 균 구게 v1.3 ¶
~cpp #include <iostream.h> #include <stdlib.h> #include <ctime> void game(); void new_game(); void main() { cout << "┌┐\n" "│ │\n" "│ │\n" "│ 구 │\n" "│ │\n" "│ 게 ver 1.3 │\n" "│ │\n" "│ │\n" "│ │\n" "│ Made by 균 │\n" "│ │\n" "└┘\n";// cout << "\n"; game(); // 게 } void game() { char random[4]; // char space[64]; // int strike = 0; // 기 int ball = 0; // 기 srand(time(NULL)); for (int i = 0; i < 4; i++) { random[i] = '0' + rand() % 9 + 1; for (int j = 0; j < i; j++) if (random[i] == random[j]) { i--; break; } } // 게 4 /*cout << random[0] << random[1] << random[2] << random[3] << endl;*/ // -_-;;; cout << "게 4 . *^^* ( : Q)\n\n"; int success = 0; // (0 = , 1 = 공) while (success == 0) { cout << " : "; cin.getline(space, 64); success = 1; if ((space[0] == 'q' || space[0] == 'Q') && space[1] == '\0') { cout << "Bye!!\n"; exit(0); } // 'Q' for (i = 0; i < 4; i++) { if (space[i] < '1' || space[i] > '9') { success = 0; break; } } // 1~9 if (space[4] != '\0') success = 0; // 4 for (i = 0; i < 3; i++) for (int h = i + 1; h < 4; h++) if (space[i] == space[h]) { success = 0; break; } // if (success == 0) continue; // 1개 걸 // 기 ... for (int j = 0; j < 4; j++) { if (space[j] == random[j]) strike++; // for (int k = 0; k < 4; k++) if (j != k && space[j] == random[k]) ball++; // else continue; } if (strike == 0 && ball == 0) { cout << "결과 : "; cout << "OUT!!"; // , 겨 'OUT' } else if (strike == 4) new_game(); // 경 new_game else { cout << "결과 : "; cout << strike << "S" << " " << ball << "B"; } // 결과 cout << endl; strike = 0; ball = 0; success = 0; // success 0 기 while } } void new_game() // 게 공 기 { cout << ". 겠까? (Y/N) : "; char ch; cin >> ch; while (ch != 'y' || ch != 'Y' || ch != 'n' || ch != 'N') { if (ch == 'y' || ch == 'Y') { while (cin.get() != '\n') continue; // y 고 기 개 거 game(); break; } else if (ch == 'n' || ch == 'N') { cout << "Bye!!\n"; exit(0); // 게 } else { cout << ". 겠까? (Y/N) : "; cin >> ch; } } } /* Ver 1.3 Update 게 기 Ver 1.2 Update 개 거기 (게 ㅜㅜ) Ver 1.1 Update 3 4 경. 거 . Ver 1.0 기 . 게 구 -_-;;; */