void MaxMin(int front,int end,int Max,int Min){ if(front == end){ Max = array[end]; Min = array[front]; }else{ int Max1,Max2,Min1,Min2,m; m = (end - front) /2 + front; MaxMin(front,m,Max1,Min1); MaxMin(m,end,Max2,Min2); Max = Max1 > Max2 ? Max1 : Max2; Min = Min1 > Min2 ? Min2 : Min1; } }
TerrainHeightmap::TerrainHeightmap(QImage heightmap, bool blackIsHigh, double fact) :Terrain() { int height = heightmap.height(); int width = heightmap.width(); pointList = new Vector3 *[width]; for (int i = 0; i < width; i++) pointList[i] = new Vector3[height]; terrain_height = height; terrain_width = width; QColor it = (heightmap.pixel(0, 0)); double gray = blackIsHigh ? 255 - ((it.red() + it.blue() + it.green()) / 3) : ((it.red() + it.blue() + it.green()) / 3); high = gray * fact; low = gray * fact; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { it = (heightmap.pixel(i, j)); gray = blackIsHigh ? 255 - ((it.red() + it.blue() + it.green()) / 3) : ((it.red() + it.blue() + it.green()) / 3); pointList[i][j] = Vector3(i, j, gray * fact); MaxMin(gray * fact); } } calcK(); }
void CSearchMap::SetStartPoint(int x, int y, int move_max) { point.x = MaxMin(x, 0, x_size - 1); point.y = MaxMin(y, 0, y_size - 1); //맵 초기화 for(int i = 0; i < x_size; i++) { for(int j = 0; j < y_size; ++j) { roadmap[i][j] = MOVE_DISABLE; } } //길 찾기 FindRoad(roadmap, point.x, point.y, 0, move_max); }
int main () { int v[6] = { 0, 10, 7, 14, 2, 1 }; maxmin *t = malloc( 1 * (sizeof ( maxmin ) ) ); MaxMin( v, 0, t); printf("%d %d", t->max, t->min); return 0; }
void PageConfigData::UpDataMaxFLow(double dx[],int nNum) { ASSERT(pConfig != NULL); double dMaxFlow = pConfig->m_MaxFlow.GetfValue(); double dMax,dMin; MaxMin(dx,nNum,dMax,dMin); if(dMax>dMaxFlow) pConfig->m_MaxFlow.SetValue(float(dMax)); }
void readProfile() { char privateFile[_MAX_PATH]; int i; GetModuleFileName(sysInf.hInstance,myPath,sizeof(myPath)); for(i=lstrlen(myPath)-1;i>0;i--){ if(myPath[i] == '\\'){ myPath[i] = '\0'; break; } } lstrcpy(privateFile,myPath); lstrcat(privateFile,"\\Routes_mini.INI"); sysInf.bgmVolume = MaxMin(10, GetPrivateProfileInt("System","BGM volume",10,privateFile)); sysInf.voiceVolume = MaxMin(10, GetPrivateProfileInt("System","VOICE volume",10,privateFile)); sysInf.seVolume = MaxMin(10, GetPrivateProfileInt("System","SE volume",10,privateFile)); sysInf.full_screen = MaxMin(1, GetPrivateProfileInt("System","Screen mode",0,privateFile)); sysInf.msgSpeed = MaxMin(10, GetPrivateProfileInt("System","Message speed",6,privateFile)); sysInf.autoMsg = MaxMin(10, GetPrivateProfileInt("System","Auto message",5,privateFile)); sysInf.bAutoRead = MaxMin(1, GetPrivateProfileInt("System","Auto Read",0,privateFile)); sysInf.bAllSkip = MaxMin(1, GetPrivateProfileInt("System","All Skip",1,privateFile)); sysInf.bGEffectSkip = MaxMin(1, GetPrivateProfileInt("System","Graphic Skip",1,privateFile)); sysInf.transparent = MaxMin(100, GetPrivateProfileInt("System","Transparent",50,privateFile)); sysInf.refreshRate = 0; if(sysInf.full_screen){ char workBuf[512]; sysInf.refreshRate = 0; if(CheckOSw2k()){ sysInf.refreshRate = GetPrivateProfileInt("System","Refresh rate",0,privateFile); } if(sysInf.refreshRate>0){ wsprintf(workBuf,"前回の画面設定:\nフルスクリーン,リフレッシュレート:%dHzで起動します。\nよろしいですか?",sysInf.refreshRate); }else{ strcpy(workBuf,"前回の画面設定:\nフルスクリーン,リフレッシュレート:標準で起動します。\nよろしいですか?"); } if(IDNO==MessageBox(NULL,workBuf,"画面切り替え確認",MB_YESNO|MB_ICONQUESTION)){ sysInf.full_screen = 0; sysInf.refreshRate = 0; } } } // readProfile
/* nama :dyarsa S.Pamungkas Nim :A11.2011.06186 Klmpk: A11.4204 ---copyright dy_arsa--- */ int main() { TabInt T,T1,T2,TCopy,TInv,TSim,TBaca; int i; MakeEmpty(&T1); for (i=1;i<=10;i++) { T1.TI[i]=i; } TulisIsiTab(T1); // printf("Tekan sembarang tombol untuk melanjutkan....\n");getch(); printf("\n"); printf("Empty T=1, F=0 :%d\n",IsEmpty(T1)); printf("Full T=1, F=0 :%d\n",IsFull(T1)); // printf("Tekan sembarang tombol untuk melanjutkan....\n");getch(); printf("\n"); printf("index 0 :%s\n",IsIdxValid(T1,0)?"Ya":"Tidak"); printf("index 1 :%s\n",IsIdxValid(T1,1)?"Ya":"Tidak"); printf("index 5 :%s\n",IsIdxValid(T1,5)?"Ya":"Tidak"); printf("index 10 :%s\n",IsIdxValid(T1,10)?"Ya":"Tidak"); printf("index 101 :%s\n",IsIdxValid(T1,101)?"Ya":"Tidak"); printf("GetFirstIdx Efektif] :%d\n",GetFirstIdx(T1)); printf("GetLastIdx Efektif :%d\n",GetLastEfIdx(T1)); printf("\n"); MakeEmpty(&T2); for (i=1;i<=10;i++) { T2.TI[i]=i*2+1; } printf("T1\n"); TulisIsiTab(T1); printf("\nT2 \n"); TulisIsiTab(T2); printf("\n"); printf("\nT1+T2 :\n"); PlusTab(T1,T2); printf("\nT2-T1 :\n"); MinusTab(T2,T1); printf("\nT1*T2 :\n");KaliTab(T1,T2); printf("\nT1*2:\n"); KaliKons(T1,2); printf("\nApakah T1 Sama dg T2?: %s\n",IsEQ(T1,T2)?"Ya":"Tidak"); printf("\nApakah T1 Kurang dari T2?: %s\n",IsLess(T1,T2)?"Ya":"Tidak"); printf("\nApa Nilai Maksimum tabel T1?: %i\n",ValMax(T1)); printf("\nApa Nilai Minimum tabel T1?: %i\n",ValMin(T1)); printf("\nApa index Nilai Maksimum tabel T2?: %i\n",IdxMaxTab(T2)); printf("\nApa index Nilai Minimum tabel T2?: %i\n",IdxMinTab(T2)); printf("\nApa Nilai Maksimum tabel T?: %i\n",Max(T)); printf("\nApa Nilai Minimum tabel T?: %i\n",Min(T)); printf("\nApa Nilai MaksMin tabel T?: ");MaxMin(T); return 0; }
void MatrixStat::TimeDistribute(int64_t value) { if (distribution_.size() != kTotalBucket) {// 10 seconds, each bucket 100 us distribution_.resize(kTotalBucket); } MaxMin(value); ++count_; value_ += value; uint32_t bucket = (uint32_t)(value / kBucketUsec); if (bucket >= kTotalBucket) { bucket = kTotalBucket - 1; } ++distribution_[bucket]; }
// Renvoi un terrain généré aléatoirement TerrainFractal::TerrainFractal ( unsigned int terrain_width_, unsigned int terrain_height_ ) : Terrain ( ) { terrain_width = terrain_width_; terrain_height = terrain_height_; high = ( low = Noise::noise ( 0., 0. ) ); // Pour récuperer le Low and Height for ( unsigned int j = 0; j < terrain_height; j++ ) { for ( unsigned int i = 0; i < terrain_width; i++ ) { MaxMin ( Noise::noise ( i, j ) ); } } calcK ( ); }
BOOL CSearchMap::MoveNextPointStupid(int move, int iq) { iq = MaxMin(iq, 1, 10); //아이큐는 1~10까지 //가장 좋은 길을 찾기 int best_dir = dir_none, best_expense = distancemap[point.x][point.y] + (10 - iq); //멍청하기 때문에 모두 검사하지 않고 몇개를 랜덤으로 시도해 본 뒤 그 중에서 이동 BOOL left_ok, right_ok, up_ok, down_ok; left_ok = right_ok = up_ok=down_ok = FALSE; int count = 0; while(count < iq && (!left_ok || !right_ok || !up_ok || !down_ok)) { int ran = rand() % 4; //왼쪽 검사 if(ran == dir_left) { if(point.x > 0 && distancemap[point.x - 1][point.y] < best_expense && map[(point.x - 1) + point.y * x_size] <= move) { best_dir = dir_left; best_expense = distancemap[point.x - 1][point.y]; } left_ok = TRUE; } //오른쪽 검사 else if(ran == dir_right) { if(point.x < x_size - 1 && distancemap[point.x + 1][point.y] < best_expense && map[(point.x + 1) + point.y * x_size] <= move) { best_dir = dir_right; best_expense = distancemap[point.x + 1][point.y]; } right_ok = TRUE; } //위 검사 else if(ran == dir_up) { if(point.y > 0 && distancemap[point.x][point.y - 1] < best_expense && map[point.x + (point.y - 1) * x_size] <= move) { best_dir = dir_up; best_expense = distancemap[point.x][point.y - 1]; } up_ok = TRUE; } //아래 검사 else if(ran == dir_down) { if(point.y < y_size - 1 && distancemap[point.x][point.y + 1] < best_expense && map[point.x + (point.y + 1) * x_size] <= move) { best_dir = dir_down; best_expense = distancemap[point.x][point.y + 1]; } down_ok = TRUE; } count++; } //가장 가까운 곳으로 이동(아니면 가만히 있음) if(best_dir == 0) { point.x--; } else if(best_dir == 1) { point.x++; } else if(best_dir == 2) { point.y--; } else if(best_dir == 3) { point.y++; } //목적지에 도착하면 TRUE, 아니면 FALSE if(distancemap[point.x][point.y] == 0) { return TRUE; } else { return FALSE; } }