#include <iostream>
#include <ctime>


using namespace std;

/*
7개의 변수를 선언.

변수들에 1~7범위의 난수를 대입.

if문을 통해 중복된 숫자가 나올 경우 반복반복

모든값을 다뽑았으면 출력!
*/

int main(void)
{
 int iLotto1=0, iLotto2=0, iLotto3=0, iLotto4=0, iLotto5=0, iLotto6=0, iLotto7=0; //로또번호를 담을 변수들
 
 srand( (unsigned int)time(NULL) );//랜덤한 시드를 부여


 iLotto1 = ( rand() %7 ) +1;

 iLotto2 = ( rand() %7 ) +1;

 iLotto3 = ( rand() %7 ) +1;

 iLotto4 = ( rand() %7 ) +1;

 iLotto5 = ( rand() %7 ) +1;

 iLotto6 = ( rand() %7 ) +1;

 iLotto7 = ( rand() %7 ) +1;

 

 while(1)
 {
  if(iLotto2 == iLotto1)
  {
   iLotto2 = ( rand() %7 ) +1;

   continue;
  }

  else if( iLotto3 == iLotto2 || iLotto3 == iLotto1 )
  {
   iLotto3 = ( rand() %7 ) +1;

   continue;
  }
  
  else if(  iLotto4 == iLotto3 || iLotto3 == iLotto2 || iLotto4 == iLotto1 )
  {
   iLotto4 = ( rand() %7 ) +1;

   continue;
  }
  
  else if( iLotto5 == iLotto4 || iLotto5 == iLotto3 || iLotto5 == iLotto2 || iLotto5 == iLotto1 )
  {
   iLotto5 = ( rand() %7 ) +1;

   continue;
  }

  else if(  iLotto6 == iLotto5 || iLotto6 == iLotto4 || iLotto6 == iLotto3 || iLotto6 == iLotto2 || iLotto6 == iLotto1 )
  {
   iLotto7 = ( rand() %7 ) +1;

   continue;
  }

  else if( iLotto7 == iLotto6 || iLotto7 == iLotto5 || iLotto7 == iLotto4 || iLotto7 == iLotto3 || iLotto7 == iLotto2 || iLotto7 == iLotto1 )
  {
   iLotto7 = ( rand() %7 ) +1;

   continue;
  }

  else
  {
   break;
  }

 }

 cout << iLotto1 << endl
   << iLotto2 << endl
   << iLotto3 << endl
   << iLotto4 << endl
   << iLotto5 << endl
   << iLotto6 << endl
   << iLotto7 << endl;
 

 return 0;
}



로또번호생성기인데

이게 웃긴게 cout이 출력됬다가 안됬다가

아무 수정없이 함 컴파일할떄마다 뜰때도있고 안뜰때도있음


랜덤수를 뽑으려고하니까 출력도 랜덤으로됨 ㅋㅋ 허참


이거땜에 몇시간째 잡고씨름중인데 내실력으로 도저히 뭐때문에 버그가나는지 알수가없음.. 컴파일할때도 에러뜨는거 하나도없고


으아아ㅏ제발도와주세여