U E D R , A S I H C RSS

데블스캠프2006/월요일/함수/문제풀이/김준석

실미도 함수 만들기 (몸통은 자유)



~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/월요일/함수/문제풀이
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:05
Processing time 0.0094 sec