์ฝ๋
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int big (int a, int b){
if(a>b) return a;
else return b;
}
int big(int a[], int size){
int res = a[0];
for(int i = 1; i<size; i++)
if(res < a[i]) res = a[i];
return res;
}
int small (int a, int b){
if(a>b) return b;
else return a;
}
int small(int a[], int size){
int res = a[0];
for(int i = 1; i<size; i++)
if(res > a[i]) res = a[i];
return res;
}
void lotto(int y[], string s,int size=6){
/* for(int i=0; i< size; i++){
if(s == "์ค๋ณต ๋ถ๊ฐ๋ฅ ๋ก๋"){
์ค๋ณต ์ ๊ฑฐ ์๊ณ ๋ฆฌ์ฆ
int res = y[0];
for(int i = 1; i<size; i++){
if(res == y[i]) --i;
}
}
int r = rand()%45+1;
cout<<r<<endl;
}
cout <<size<<endl;
*/
if(s =="๋ก๋ ์ค๋ณต ๊ฐ๋ฅ"){
cout<<"์ค๋ณต ๊ฐ๋ฅ ๋ก๋ : ";
for(int i =0; i<size; i++){
y[i]=rand()%45+1;
cout<<y[i]<<", ";
}
cout<<endl;
}else {
// y[0] = rand()%45+1;
for(int i =1; i<size; i++){
y[i]=rand()%45+1;
for(int j = 0;j<i;j++){
if(y[i]==y[j]){
--i;
break;
}
}
}
cout<<endl<<"์ค๋ณต ๋ถ๊ฐ ๋ก๋ : ";
for (int i = 0;i<size;i++){
cout<<y[i]<<", " ;
}
}
}
int main()
{
//int ar[] = {1,8,-3,4,6,7,8,6,4,56,4};
//cout<<big(2,3)<<endl;
//cout<<"์ต๋ ๊ฐ : "<<big(ar,sizeof(ar)/sizeof(ar[0]))<<endl;
//cout<<small(2,3)<<endl;
//cout<<"์ต์ ๊ฐ : "<<small(ar,sizeof(ar)/sizeof(ar[0]))<<endl;
srand(time(NULL));
// int r = rand()%100+1;//1~100 ์ฌ์ด์ ์์์ ์
// cout<<r<<endl;
int x[6];
lotto(x,"๋ก๋ ์ค๋ณต ๊ฐ๋ฅ" );
lotto(x,"์ค๋ณต ๋ถ๊ฐ๋ฅ ๋ก๋", sizeof(x)/sizeof(x[0]));
return 0;
}
๊ฒฐ๊ณผ