U E D R , A S I H C RSS

데블스캠프2006/월요일/함수/문제풀이/이장길

이장길

실미도

#include <iostream.h>

bool team684(int, int, int);

int main(void)
{	
	int people, gun, boat;

	cout<<"대원수, 권총수, 보트수를 차례대로 입력하세요."<<endl;

	cin>>people>>gun>>boat;

	team684(people, gun, boat);

	return 0;
}

bool team684(int l, int m, int n)
{
	if(l >= 20 && m>=20 && n >=2){
		cout<<"ture"<<endl;
	}
	else {
		cout<<"die"<<endl;
	}
	return 0;
}
	

주사위
#include <iostream>
using namespace std;
#include <time.h>

int ran();

int main(void)
{
	srand((unsigned)time(NULL));
	ran();
	cout<<ran()<<endl;
	return 0;
}

int ran()
{	
	
	return (rand()%6)+1;	
}

백설공주와 일곱난쟁이

#include <iostream>
using namespace std;
#include <time.h>

int short1();
int short2();
int short3();
int short4();
int short5();
int short6();
int short7();
int princess();

int main()
{
	srand((unsigned)time(NULL));
	int num;
	num = rand()%8;

	
	if(num == 0){
		cout<<"첫째야"<<endl<<endl;
		short1();
	}
	else if(num == 1){
		cout<<"둘째야"<<endl<<endl;
		short2();
	}
	else if(num == 2){
		cout<<"셋째야"<<endl<<endl;
		short3();
	}
	else if(num == 3){
		cout<<"넷째야"<<endl<<endl;
		short4();
	}
	else if(num == 4){
		cout<<"다섯째야"<<endl<<endl;
		short5();
	}
	else if(num == 5){
		cout<<"여섯째야"<<endl<<endl;
		short6();
	}
	else if(num == 6){
		cout<<"막내야"<<endl<<endl;
		short7();
	}
	else if(num == 7){
		cout<<"공주야"<<endl<<endl;
		princess();
	}
	return 0;
}

int short1()
{
	cout<<"첫째입니다."<<endl;
	short2();
	return 0;
}
int short2()
{
	cout<<"둘째입니다."<<endl;
	short3();
	return 0;
}

int short3()
{
	cout<<"셋째입니다."<<endl;
	short4();
	return 0;
}

int short4()
{
	cout<<"넷째입니다."<<endl;
	short5();
	return 0;
}

int short5()
{
	cout<<"다섯째입니다."<<endl;
	short6();
	return 0;
}

int short6()
{
	cout<<"여섯째입니다."<<endl;
	short7();
	return 0;
}

int short7()
{
	cout<<"일곱째입니다."<<endl;
	princess();
	return 0;
}

int princess()
{
	cout<<"공주입니다."<<endl;
	return 0;	
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:05
Processing time 0.0112 sec