기금넷 공식사이트 - 복권 조회 - C++ 로 작성된 프로그램 코드 찾기
C++ 로 작성된 프로그램 코드 찾기
# include & ltWindows.h & gt
# include & lt 문자열>
# include & ltcstdlib & gt
# include & ltctime & gt
네임스페이스 STD 사용
Void inputdata (intuserdate []); //사용자 번호를 입력합니다
Void generator anddata (int rand data []); //시스템에서 난수를 생성합니다
Voidprintdata (inta []); //출력 번호
String comparedata (int userdata [], int rand data []); //당첨 정보를 비교해서 당첨 상황을 제시하다.
Voidsort (intb []); //배열 정렬
Int main ()
{
Char choice =' y
While(choice=='y'||choice=='Y')
{
Intuser data [7];
Int rand data [7];
Cout & lt& lt "1~35 범위에 7 개의 반복되지 않는 정수를 입력하십시오."
InputData (사용자 데이터);
Sort (사용자 데이터);
Cout & lt& lt "입력한 번호는 다음과 같습니다."
PrintData (사용자 데이터);
Srand (시간 (0));
Generateranddata (randdata);
Sort (rand data);
Cout & lt& lt "이번 추첨 번호는" < & ltendl
Printdata (randdata);
Stringstrinfo = comparedata (사용자 데이터, randdata);
Cout & lt& lt "이번에 산 복권 당첨 정보는" < & ltendl
수면 (1000);
수면 (1000);
시스템 ("cls");
Cout & lt& ltstrInfo
Cout & lt& lt" \ n 다시 놀고 싶니? (y/n) "< & ltendl
CIN>;; & gt 선택;
}
시스템 ("일시 중지");
}
Void InputData(int userData[]) 입니다
{
For(int I = 0;; 나<7; I++)
{int a;; CIN>;; & gta;;
While(a & lt;; 1| | | a >; (35)
{cout & lt& lt" \ n 오류! 다시 입력: "<& ltendl
CIN>;; & gta;; }
사용자 데이터 [I] = a; }
}
Void generator addata (int rand data []) 입니다
{
For(int I = 0;; 나<7; I++)
{
Inta =1+rand ()% 35;
Intcounter = 0;
If (I = = 0) rand data [I] = a;
기타
{while (카운터! =i)
{
A =1+rand ()% 35;
카운터 = 0;
For(int j = 0;; J< 나; J++)
{
만약 (a! =randData[j])
카운터+=1;
그렇지 않으면 계속합니다.
}
}
Rand data [I] = a;
}
}
}
Void PrintData(int a[]) 입니다
{
For(int I = 0;; 나<7; I++)
Cout & lt<A [I] < & lt "";
Cout & lt& ltendl
}
String comparedata (int userdata [], int randData[])
{
Intcounter = 0;
For(int I = 0;; 나<7; I++)
{
For(int j = 0;; J<7; J++)
{
If(userData[i]==randData[j])
카운터+=1;
}
}
스위치 (카운터)
{
시나리오 1: 시나리오 2: 시나리오 3:
사례 4: 반환' 위로상! \ n 의무 $0.0 1! ";
사례 5: 보상 "3 등상! \ n 의무 $ 10! ";
사례 6: 보상 "2 등상! \ n 책임 $ 10000! ";
사례 7: 보상 "1 등상! \ n onus $ 10000000! ";
}
}
Void 정렬 (int b[])
{
For (intpass = 0; & lt6; 을 통해 Pass++)
{
For(int I = 0;; 나<6; I++)
{
If (b [I] > B[i+ 1])
{inttemp = b [I]; B [I] = b [I+1]; B [I+1] = temp; }
}
}
}