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 . 트 -_-;;; */