분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #include<iostream> #include<algorithm> using namespace std; #define MAXNUM 20 #define TOTAL 300 class MakeRandom{ protected: int random[TOTAL]; public: void Random(){ for(int i=0;i<TOTAL;i++){ random[i] = rand()%1000; } } }; class MakeRun : public MakeRandom{ protected: int *buf; public: void MakeBuf(){ Random(); buf = (int*)malloc(sizeof(int)*MAXNUM); for(int i=0;i<MAXNUM;i++){ buf[i] = random[i]; } } void MoveRandom(int temp){ for(int i=0;i<temp-MAXNUM;i++){ random[i] = random[i+MAXNUM]; } } }; class Replacement :public MakeRun{ protected: int run[MAXNUM][TOTAL]; int frozen[MAXNUM]; int runnum; int total; public: Replacement(){ runnum=0; total = TOTAL; } void MakeRun(){ int temp=0; //동결된 항 갯수 카운트용 임시변수 int temp2=0; //run배열을 만들때 사용할 임시변수 int temp3=0; //각 런의 갯수를 담아둘 임시변수 int temp4=MAXNUM; //버퍼의 갯수를 저장하는 변수 cout<<"Make Runn"; do{ MakeBuf(); MoveRandom(total); do{ sort(buf, buf+MAXNUM); run[runnum][temp2] = buf[0]; buf[0] = random[temp2]; if(run[runnum][temp2] > buf[0]){ frozen[temp]=buf[0]; for(int i=0;i<MAXNUM-(temp2+1);i++){ buf[i]=buf[i+1]; buf[MAXNUM-(temp+1)]=1001; } temp++; } else{ } temp2++; }while(temp!=MAXNUM); runnum++; total -=temp2; temp3 = temp2; temp2 = 0,temp = 0; sort(run[runnum-1],run[runnum-1]+temp3); cout<<endl<<runnum<<"번째 RUN 입니다"<<endl; for(int i=0;i<temp3;i++){ cout<<run[runnum-1][i]<<" "; } cout<<temp3<<endl; cout<<endl; }while(total >= 0); cout<<endl<<"총 "<<runnum<<"개의 RUN이 생성되었습니다.n"; } }; class Amalgamation:public Replacement{ protected: int storage; int lastFile[TOTAL]; public: }; void main(){ system("cls"); Replacement test; test.MakeRun(); } |
죄송합니다. 댓글 작성은 회원만 가능합니다.