void main(void) { int array[MAX]; int x; printf("wuwedi x\n"); scanf("%d\n", &x); fillarray(array); sortarray(array); printf("sortiraniyat masiw:"); printarray(array); }
main() { int size_local; double most, least; double price_list[MAX_PRICES]; printf("\nPrices Before Sorting of Array:"); readarray(price_list, &size_local); sortarray(price_list, size_local, &most, &least); printf("\n\nPrices After Sorting of Array:"); displayarray(price_list, size_local); printf("\n"); display(most, least); }
//Get the central point between the two parallel lines CvPoint getcentralpoint(IplImage *image, CvSeq *res) { CvPoint *pnt1, *pnt2, *pnt3, *pnt4, *pnt5, *pnt6; double dif1, dif2, dif3; int dif; CvPoint tmpPnt1, tmpPnt2, tmpPnt3; fillarray(res); sortarray(); if(ORIENT_ARRAY_SIZE == 8){ //get the points pnt1 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-3][0],0); pnt2 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-3][1],0); pnt3 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-2][0],0); pnt4 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-2][1],0); pnt5 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-1][0],0); pnt6 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-1][1],0); //get directions of the lines dif1 = difference(pnt1, pnt2, pnt3, pnt4, 'x') + difference(pnt1, pnt2, pnt3, pnt4, 'y'); dif2 = difference(pnt1, pnt2, pnt5, pnt6, 'x') + difference(pnt1, pnt2, pnt5, pnt6, 'y'); dif3 = difference(pnt3, pnt4, pnt5, pnt6, 'x') + difference(pnt3, pnt4, pnt5, pnt6, 'y'); //get lines who run parallel to each other //dir3 = line 1 and 2 //dir4 = line 1 and 3 //dir5 = line 2 and 3 if ((dif1 <= dif2) && (dif1 <= dif3)) dif = 3; if ((dif2 <= dif1) && (dif2 <= dif3)) dif = 4; if ((dif3 <= dif1) && (dif3 <= dif2)) dif = 5; //estimate middle point between two parallel lines if (dif == 3) { tmpPnt1 = centralpoint(*pnt3, *pnt4); tmpPnt2 = centralpoint(*pnt1, *pnt2); tmpPnt3 = centralpoint(tmpPnt1, tmpPnt2); } if (dif == 4) { tmpPnt1 = centralpoint(*pnt5, *pnt6); tmpPnt2 = centralpoint(*pnt1, *pnt2); tmpPnt3 = centralpoint(tmpPnt1, tmpPnt2); } if (dif == 5) { tmpPnt1 = centralpoint(*pnt3, *pnt4); tmpPnt2 = centralpoint(*pnt5, *pnt6); tmpPnt3 = centralpoint(tmpPnt1, tmpPnt2); } } if(ORIENT_ARRAY_SIZE == 12){ pnt3 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-2][0],0); pnt4 = (CvPoint*)cvGetSeqElem(res,points[ORIENT_ARRAY_SIZE-2][1],0); tmpPnt3 = centralpoint(*pnt3, *pnt4); } //print center point in image //cvCircle(image, tmpPnt1, 10, CV_RGB(100,100,100), 2); //return the central point return tmpPnt3; }