미 만들기 (몸 ) ¶
~cpp
#include<iostream>
#include<time.h>
using namespace std;
bool team684(int daewon, int weapon_num, int boat_num){
if(daewon >= 40 && (daewon/boat_num)<8 && (weapon_num/daewon >=1)) return true;
else return false;
}
void main(){
srand((unsigned)time(0));
int daewon, weapon_num, boat_num;
cout << "대 40명 보당 대 7명 모든 대게 무기급다면 공!" << endl;
cout << "대 보 기 대로 력" << endl;
cin >> daewon >> boat_num >> weapon_num;
if(team684(daewon, weapon_num, boat_num)){
cout << "대 명당" <<(rand()%(daewon/10) +1) * (int)(weapon_num/daewon) << "명고 " << endl;
cout << "공!!" << endl;
}
else {
cout << (rand()%(weapon_num/10) +1) / daewon << "명고 " << endl;
cout << "!!" << endl;
}
}
Dice() 1~6 ¶
~cpp
#include<iostream>
#include<time.h>
using namespace std;
int dice(){
srand((unsigned)time(NULL));
return rand() % 6 + 1;
}
void main(){
cout << "나 값 " << dice() << "다." <<endl;
}
공 난 ¶
~cpp
#include<iostream>
#include<time.h>
using namespace std;
void call_one();
void call_two();
void call_three();
void call_four();
void call_five();
void call_six();
void call_seven();
void call_back();
void main(){
srand(time(0));
switch(rand()%7){
case 0: call_one(); break;
case 1: call_two(); break;
case 2: call_three(); break;
case 3: call_four(); break;
case 4: call_five(); break;
case 5: call_six(); break;
case 6: call_seven(); break;
}
}
void call_one(){
cout << " 난 -> ";
call_two();
call_three();
call_four();
call_five();
call_six();
call_seven();
}
void call_two(){
cout << "둘 난 ->";
call_three();
call_four();
call_five();
call_six();
call_seven();
}
void call_three(){
cout << " 난 ->";
call_four();
call_five();
call_six();
call_seven();
}
void call_four(){
cout << " 난 ->" ;
call_five();
call_six();
call_seven();
}
void call_five(){
cout << "다 난 ->";
call_six();
call_seven();
}
void call_six(){
cout << " 난 ->";
call_seven();}
void call_seven(){
cout << " 난 ->";
call_back();
}
void call_back(){ cout << "공" << endl;
}
데블2006///문









