void main() { int a[] = {1, 2, 3, 4, 5}; int b[] = {6, 7, 8, 8, 10, 11, 12, 0, 1, 12, 2, 3}; int c[] = {-1, -2, -3, -4, -5}; printf("Biggest of A = %d\n", biggest(a, sizeof(a) / sizeof(int))); printf("Biggest of B = %d\n", biggest(b, sizeof(b) / sizeof(int))); printf("Biggest of C = %d\n", biggest(c, sizeof(c) / sizeof(int))); }
/*! Checks whether a single layout object shape will fit into one of the childrens quadTree. It calls add() and returns success if the new layout object fits entirely into one of the possible subtrees or if it blows up its overlaping area not more than 10%. Returns false if the shape does not fit anywhere - means it should be placed higher into the quadTree structure.\n The method might be called recursively via the add() method. */ bool laydata::quadTree::fitintree(tdtdata* shape) { DBbox shovl = shape->overlap(); float clipedarea[4]; // check the clipping to see in witch region to place the shape for (byte i = 0; i < 4 ; i++) { DBbox subbox = _overlap.getcorner(i); clipedarea[i] = subbox.cliparea(shovl,true); if (-1 == clipedarea[i]) {//entirely inside the area if (!_quads[i]) _quads[i] = DEBUG_NEW quadTree(); _quads[i]->add(shape); return true; } } // if we got to this point - means that the shape does not fit // entirely inside neither of the four sub-areas. // It is a decision time then byte candidate = biggest(clipedarea); // now calculate the eventual new overlaping box DBbox newovl = _overlap.getcorner(candidate); newovl.overlap(shovl); // if the max area of the candidate does not blow more than 10% - // then seems to be OK to get it if (newovl.area() < 1.1 * (_overlap.area() / 4)) { if (!_quads[candidate]) _quads[candidate] = DEBUG_NEW quadTree(); _quads[candidate]->add(shape); return true; } return false; // shape can not be fit into any subtree }
bool isValidBST(TreeNode *root) { // Note: The Solution object is instantiated only once and is reused by each test case. if(root == NULL) { return true; } int valT = root->val; if(root->left != NULL) { if(biggest(root->left) >= valT) { return false; } if(!isValidBST(root->left)) { return false; } } if(root->right != NULL) { if(smallest(root->right) <= valT) { return false; } if(!isValidBST(root->right)) { return false; } } return true; }
int main() { /* Test sum */ int a[3] = {1, 2, 3}; printf("1. sum returned %d. Expecting 6.\n", sum(a, 3)); int b[1] = {10}; printf("2. sum returned %d. Expecting 10.\n", sum(b, 1)); /* Test biggest */ printf("3. biggest returned %d. Expecting 3.\n", biggest(a, 3)); printf("4. biggest returned %d. Expecting 10\n", biggest(b, 1)); int c[4] = {4, -1, 0, 3}; printf("5. biggest returned %d. Expecting 4\n", biggest(c, 1)); int d[3] = {-4, -1, -5}; printf("6. biggest returned %d. Expecting -1\n", biggest(d, 3)); /* Test average */ printf("7. average returned %f. Expecting 2.0\n", average(a, 3)); printf("8. average returned %f. Expecting 10.0\n", average(b, 1)); printf("9. average returned %f. Expecting 1.5\n", average(c, 4)); printf("10. average returned %f. Expecting -3.3333\n", average(d, 3)); /* Test reverse */ printf("Reversing d - original: "); print_array(d, 3); printf(" reversed: "); reverse(d, 3); print_array(d, 3); printf("Reversing c - original: "); print_array(c, 4); printf(" reversed: "); reverse(c, 4); print_array(c, 4); printf("Reversing b - original: "); print_array(b, 1); printf(" reversed: "); reverse(b, 1); print_array(b, 1); return 0; }
int main() { node * head = cllbuild(); getchar(); node *head2 = cllbuild(); //merge clists by max node * inithead = head; head = biggest(head); head2 = biggest(head2); node * cur; for(cur = head2; cur->next != head2; cur = cur->next); node * tail = head->next; head->next = head2; cur->next = tail; //display cdisplay(inithead); return 0; }
int main() { int num1, num2, num3; printf("Enter three numbers:\n"); scanf("%d%d%d", &num1, &num2, &num3); printf("The biggest number is %d", biggest(num1, num2, num3)); return 0; }
// Function for Sorting 3 Floating point Numbers void sort(float *no1, float *no2, float *no3){ float *numbersToSort[3] = {no1, no2, no3}; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ biggest(numbersToSort[i],numbersToSort[j]); } } }
int main(int argc, const char *argv[]) { float a,b,c; printf("digite o primeiro numero:"); scanf("%f",&a); printf("digite o segundo numero:"); scanf("%f",&b); printf("digite o terceiro numero:"); scanf("%f",&c); printf("%.2f",biggest(a,b,c)); return 0; }
int main() { int a = 0; int b = 0; int c = 0; printf("enter three number:"); scanf("%d %d %d", &a, &b, &c); printf("the biggest one is:%d\n",biggest(a,b,c)); return 0; }
/*! Checks whether a single layout object shape will fit into one of the childrens quadTree. Returns the index of the child quadTree which fits the shape or -1 otherwise. */ int laydata::quadTree::fitsubtree(DBbox shovl, DBbox* maxsubbox ) { float clipedarea[4]; // check the clipping to see in witch region to place the shape for (byte i = 0; i < 4 ; i++) { clipedarea[i] = maxsubbox[i].cliparea(shovl,true); if (-1 == clipedarea[i]) {//entirely inside the area return i; } } // if we got to this point - means that the shape does not fit // entirely inside neither of the four sub-areas. // It is a decision time then byte candidate = biggest(clipedarea); // now calculate the eventual new overlaping box DBbox newovl = maxsubbox[candidate]; newovl.overlap(shovl); // if the max area of the candidate does not blow more than 10% - // then seems to be OK to get it if (newovl.area() < 1.1 * (_overlap.area() / 4)) { return candidate; } return -1; // shape can not be fit into any subtree }
inline void update_max(U8* max, I32 dim=0) { this->max[dim] = biggest(cast(max), this->max[dim]); }
std::vector<Vector3 *> Scene::traceLine(Camera const *cam, Image const *img, int j) const { std::vector<Vector3 *> results(img->width()); Ray ray; HitInfo hitInfo; Vector3 shadeResult; std::vector<float> refr_stack; std::vector<Vector3> colors(m_samples); for (int i = 0; i < img->width(); ++i) { for (int k = 0; k < m_samples; ++k) { ray = cam->eyeRay(i + (m_samples == 1 ? 0.5f : randone(g_rng) - 0.5f), j + (m_samples == 1 ? 0.5f : randone(g_rng) - 0.5f), img->width(), img->height()); if (m_focus_length >= 0.f) // if depth of field enabled { Vector3 focal_point = ray.o + m_focus_length * ray.d; Vector3 view_dir = cam->viewDir(); Vector3 d_vec(randone(g_rng) - 0.5f, randone(g_rng) - 0.5f, randone(g_rng) - 0.5f); d_vec.normalize(); d_vec = view_dir.cross(d_vec); ray.o += d_vec * randone(g_rng) * m_lens; ray.d = focal_point - ray.o; ray.d.normalize(); } refr_stack.clear(); refr_stack.push_back(1.f); ray.refractionStack = &refr_stack; ray.refractionIndex = 0; if (!results[i]) results[i] = new Vector3(); if (trace(hitInfo, ray)) { colors[k] = hitInfo.material->shade(ray, hitInfo, *this); } else { colors[k] = bgColor(); } *results[i] += colors[k]; } if (m_cutoffs > 0) { std::vector<int> biggest(m_cutoffs, -1); for (int c = 0; c < m_cutoffs; ++c) { if (biggest[0] == -1 || colors[c].length2() > colors[biggest[0]].length2()) { biggest[0] = c; for (int k = 1; k < m_cutoffs; ++k) { if (biggest[k] == -1 || colors[biggest[k - 1]].length2() > colors[biggest[k]].length2()) std::swap(biggest[k - 1], biggest[k]); else break; } } } for (int k = 0; k < m_cutoffs; ++k) *results[i] -= colors[biggest[k]]; } if (results[i]) *results[i] /= m_samples - m_cutoffs; } return results; }