int main() {
	// 2 1 3
	ListNode l1(2), l2(1), l3(3);
	ListNode l4(4), l5(2), l6(1), l7(6), l8(6), l9(9), l10(10), l11(11), l12(12), l13(6);
	ListNode n1(0), n2(0), n3(0), n4(1);
	l1.next = &l2;
	//l2.next = &l3;

	l4.next = &l5;
	l5.next = &l6;
	l6.next = &l7;
	l7.next = &l8;
	l8.next = &l9;
	l9.next = &l10;
	l10.next = &l11;
	l11.next = &l12;
	l12.next = &l13;

	print_list(&l1);
	Solution s;
	ListNode *result = s.removeNthFromEnd(&l1, 2);
	print_list(result);
	return 0;
}
Example #2
1
//
//    Save
//    ====
//
//    Save the information for this object to the AuditDataFile
//
bool CLocaleScanner::SaveData	(CAuditDataFile* pAuditDataFile)
{
	CLogFile log;
	log.Write("CLocaleScanner::SaveData Start" ,true);

	CString strValue;

	// Add the Category for memory
	CAuditDataFileCategory category(HARDWARE_CLASS);

	// Each audited item gets added an a CAuditDataFileItem to the category
	CAuditDataFileItem l1(V_LOCALE_CODEPAGE ,m_iCodePage);
	CAuditDataFileItem l2(V_LOCALE_CALENDARTYPE ,m_strCalendarType);
	CAuditDataFileItem l3(V_LOCALE_COUNTRY ,m_strCountry);
	CAuditDataFileItem l4(V_LOCALE_COUNTRYCODE ,m_iCountryCode);
	CAuditDataFileItem l5(V_LOCALE_CURRENCY ,m_strCurrency);
	CAuditDataFileItem l6(V_LOCALE_DATEFORMAT ,m_strDateFormat);
	CAuditDataFileItem l7(V_LOCALE_LANGUAGE ,m_strLanguage);
	CAuditDataFileItem l8(V_LOCALE_LOCALLANGUAGE ,m_strLocaleLocalLanguage);
	CAuditDataFileItem l9(V_LOCALE_OEM_CODEPAGE ,m_iOEMCodePage);
	CAuditDataFileItem l10(V_LOCALE_TIMEFORMAT ,m_strTimeFormat);
	CAuditDataFileItem l11(V_LOCALE_TIMEFORMATSPECIFIER ,m_strTimeFormatSpecifier);
	CAuditDataFileItem l12(V_LOCALE_TIMEZONE ,m_strLocaleTimeZone);

	// Add the items to the category
	category.AddItem(l1);
	category.AddItem(l2);
	category.AddItem(l3);
	category.AddItem(l4);
	category.AddItem(l5);
	category.AddItem(l6);
	category.AddItem(l7);
	category.AddItem(l8);
	category.AddItem(l9);
	category.AddItem(l10);
	category.AddItem(l11);
	category.AddItem(l12);

	// ...and add the category to the AuditDataFile
	pAuditDataFile->AddAuditDataFileItem(category);

	// we always need to get the default browser details so do here
	CAuditDataFileCategory browserCategory("Internet|Browsers|Default Browser", FALSE, TRUE);
	CAuditDataFileItem b1("Path", GetRegValue("HKEY_CLASSES_ROOT\\http\\shell\\open\\command", ""));
	browserCategory.AddItem(b1);

	pAuditDataFile->AddInternetItem(browserCategory);


	log.Write("CLocaleScanner::SaveData End" ,true);
	return true;
}
Example #3
0
File: test1.c Project: jkkm/latrace
int main(void)
{
	static const struct st3 a = {1, 2, 3, 4, 5, 6};

	l1(100);
	l2(100, 200);
	l3(100, 200, 300);
	l4(100, 200, 300, 400);
	l5(100, 200, 300, 400, 500);
	l6(100, 200, 300, 400, 500, 600);
	l7(100, 200, 300, 400, 500, 600, 700);
	l8(100, 200, 300, 400, 500, 600, 700, 800);

	d1();
	d2(43);
	d3(100, 200);
	d4(a);
	d5('a', 43, a);
	d6('a', 1);

	c1(44);
	c2(100, 'a', 3.4);
	c3(200, 2.777, 'q');
	c4(200, 1);
	c5(1.1, 2.2);
	c6(1.23, 45.6);
	c7('z', 0x200);

	a1('a');
	a2(10);
	a3(20);
	a4(102030405060LL);

	b1('a', 20);
	b2(30, 'b');
	b3(10, 20, 30, 40, 50, 60);

	s1(sx);
	s1p(&sx);
	s2(sy);
	s3(sz);
	s4(sq);
	s5(sa);
	s6(sb);

	r1();
	r3();
	r4();

	q1(200, sx);
	q2(300, 't', sx);
	q3(400, 410, sy);
	q4(500, 510, sq);
	q5(600, 610, 'z', 'q', sq);

	real1("fresh air");
	real2();

	return 0;
}
Example #4
0
static double lobatto_fn_8(double x) { return l8(x); }
Example #5
0
ClusterAddTest::ClusterAddTest()
{
    //funzione createwalls;
//    SLAM::Geometry::LineSegment l1 ( 1, 1, 3, 1) ;
//    qDebug() << "l'angolo di l1 è " << l1.angle() <<endl;
//    SLAM::Geometry::LineSegment l2 ( 4, 1, 6, 1) ;
//    SLAM::Geometry::LineSegment l3 ( 6, 1, 6, 3) ;
//    SLAM::Geometry::LineSegment l4 ( 6, 3, 3, 4) ;
//    SLAM::Geometry::LineSegment l5 ( 4, 4, 4, 6) ;
//    qDebug() << "l'angolo di l5 è " << fabs(fmod(l5.angle(),M_PI)) <<endl;
//    SLAM::Geometry::LineSegment l6 ( 4, 6, 3, 6) ;
//    SLAM::Geometry::LineSegment l7 ( 3, 6, 3, 4) ;
//    qDebug() << "l'angolo di l7 è " << fabs(fmod(l7.angle(),M_PI)) <<endl;
//    SLAM::Geometry::LineSegment l8 ( 1, 2, 3, 4) ;
//    qDebug() << "l'angolo di l8 è " << fabs(l8.angle()) <<endl;
//    SLAM::Geometry::LineSegment l9 ( 1, 2, 1, 1) ;
    SLAM::Geometry::LineSegment l1 ( 1, 1, 2, 2) ;
    SLAM::Geometry::LineSegment l2 ( 3, 3, 4, 4) ;
    SLAM::Geometry::LineSegment l3 ( 6, 6, 8, 8) ;
    SLAM::Geometry::LineSegment l4 ( 4, 1, 5, 2) ;
    SLAM::Geometry::LineSegment l5 ( 7, 0, 8, 1) ;
    SLAM::Geometry::LineSegment l6 ( 5, 5, 6, 4) ;
    SLAM::Geometry::LineSegment l7 ( 7, 3, 8, 1.95) ;
    SLAM::Geometry::LineSegment l8 ( 1, 4, 0, 5) ;
    SLAM::Geometry::LineSegment l9 ( 2, 5, 0, 7) ;
    bool isTrue = false;
    QList<ClusterAddTest::initWallStruct> consecutive;
    QList<ClusterAddTest::secondWallStruct> secondList;
    QList<SLAM::Geometry::LineSegment> list;
    list.append(l1);
    list.append(l2);
    list.append(l3);
    list.append(l4);
    list.append(l5);
    list.append(l6);
    list.append(l7);
    list.append(l8);
    list.append(l9);
    qDebug() << "Inizia il test, e la lista ha questo n° di elementi" << list.size() << endl;
    for (int i = 0; i < list.size(); ++i)  {
         qDebug() <<  "Se è vuota consecutive, appendo il primo." <<endl;
         if (consecutive.size() == 0) {
             qDebug() << "ciao, sono dentro il primo if, dovresti arrivare qui" <<endl;
            QList<SLAM::Geometry::LineSegment> prova;
            ClusterAddTest::initWallStruct temp = { fabs(fmod(list[i].angle() + M_PI , M_PI )), prova  };
            temp.line.append(list[i]);
            consecutive.append( temp );
            qDebug() << "ciao, sono alla fine del primo if, dovresti arrivare qui" << consecutive[0].line[0].length() <<endl;
        }
        else
        {
            isTrue = false;
            for (int j = 0; j < consecutive.size(); ++j)   {
                if (( fabs(fmod(list.at(i).angle() + M_PI, M_PI )) >= consecutive[j].angle - WALL_ANGLE_TOLERANCE) &&
                        ( fabs(fmod(list.at(i).angle() + M_PI, M_PI )) <= consecutive[j].angle + WALL_ANGLE_TOLERANCE))
                {
                    //Aggiorno l'angolo della struttura, TODO errore Qui, come gestico la struttura?
                    consecutive[j].angle = (consecutive[j].angle * consecutive[j].line.size() + fabs(fmod(list[i].angle() + M_PI, M_PI ))) /
                            (consecutive[j].line.size() + 1);
                    //Aggiungo la linea alla struttura.
                    consecutive[j].line.append(list.at(i));
                    isTrue = true;
                }
            }
            //Nessuna parete trovata = nuova parete!
            if (!isTrue) {
                QList<SLAM::Geometry::LineSegment> prova;
                ClusterAddTest::initWallStruct temp = { fabs(fmod(list[i].angle() + M_PI, M_PI )), prova  };
                temp.line.append(list[i]);
                consecutive.append( temp );
            }
        }
    }
    /*
    Come faccio? posso provare a trasformare i punti di ogni singolo subset attraverso l'angolo. A questo punto controllo
    quantizzo il tutto e ottengo degli intervalli = faccio un "istogramma". Tutti quelli che sono nella stessa colonna
    dell'istogramma saranno la stessa parete. Come step successivo ci piazzo le porte.
    Metodo migliore! ogni segmento è associato ad una retta
                    y = M * x + Q ed intercetta l'asse X in ( - Q / M ; 0 ) e l'asse Y in ( Q ; 0 ).
    Divido in cluster tutti i segmenti che hanno i due punti di intersezione vicini!
    */
    qDebug() << "Ora stampo le cose che stanno dentro la prima struttura, ovvero quelli con angolo uguale" <<endl;
    qDebug() << " la grandezza di consecutive è " << consecutive.size() <<endl;
    for (int count = 0; count < consecutive.size(); count++ )
    {
        qDebug() << "Ora stampo consecutive["<< count << "]" <<endl;
        qDebug() << "Che contiene "<<consecutive[count].line.size()<<endl;
        for(int ccc = 0; ccc <consecutive[count].line.size(); ccc++){
            qDebug() << "che contiene" << consecutive[count].line[ccc].x1()
                    << "," << consecutive[count].line[ccc].y1()
                    << " e " << consecutive[count].line[ccc].x2()
                    << "," << consecutive[count].line[ccc].y2() << endl;
        }
    }
//CI PROVO!
    for (int z = 0; z< consecutive.size(); z++)  {
        if( z != 0)
        {
            qDebug() << "Ora stampo le cose che stanno dentro la seconda struttura, ovvero quelli con M uguale" <<endl;
            qDebug() << " la grandezza di secondList è " << secondList.size() << "quando z="
                        << z << endl;
            for (int count = 0; count < secondList.size(); count++ )
            {
                qDebug() << "Ora stampo secondList["<< count << "]" <<endl;
                qDebug() << "Che contiene "<<secondList[count].line.size()<<endl;
                for(int ccc = 0; ccc <secondList[count].line.size(); ccc++){
                    qDebug() << "che contiene" << secondList[count].line[ccc].x1()
                            << "," << secondList[count].line[ccc].y1()
                            << " e " << secondList[count].line[ccc].x2()
                            << "," << secondList[count].line[ccc].y2() << endl;}}

        }
        secondList.clear();
         qDebug() << secondList.size() <<endl;
        for (int i = 0; i < consecutive[z].line.size(); ++i)  {
            //Se è vuota consecutive, appendo il primo.
            if ( secondList.size() == 0 ) {
                //TODO Sarà corretta sta roba? c'è uguale anche 30 righe sopra
                QList<SLAM::Geometry::LineSegment> altraProva;
                ClusterAddTest::secondWallStruct temp2 = {consecutive.at(z).line.at(i).m(),
                                                           consecutive.at(z).line.at(i).q(),
                                                          - consecutive.at(z).line.at(i).q() / consecutive.at(z).line.at(i).m(),
                                                          altraProva};
                temp2.line.append(consecutive[z].line[i]);
                secondList.append(temp2);
            }
            else
            {
                isTrue = false;
                for (int j = 0; j < secondList.size(); ++j)   {
                    //TODO Modifica 24 maggio 2012;
                    qDebug() << "consecutive...q() vale " << consecutive[z].line.at(i).q() <<
                                " e invece secondlist.q vale " << secondList[j].Q <<endl;
                    qDebug() << "consecutive...QM() vale " <<consecutive[z].line.at(i).q()/ consecutive[z].line.at(i).m() <<
                                " e invece secondlist.q vale " <<  secondList[j].QM <<endl;
                    if ((consecutive[z].line.at(i).q() >= secondList[j].Q - M_TOLERANCE) &&
                            (consecutive[z].line.at(i).q() <= secondList[j].Q + M_TOLERANCE) &&
                            (0 -  (consecutive[z].line.at(i).q()/ consecutive[z].line.at(i).m()) >=
                             (secondList[j].QM - QM_TOLERANCE) ) &&
                            (0 -  (consecutive[z].line.at(i).q()/ consecutive[z].line.at(i).m()) <=
                             secondList[j].QM + QM_TOLERANCE))
                    {
                        //Aggiorno l'M  e Q e QM della struttura, TODO errore Qui, come gestico la struttura?
                        secondList[j].M = (secondList[j].M * secondList[j].line.size() + consecutive[z].line.at(i).m()) /
                                (secondList[j].line.size()+1);
                        secondList[j].Q = (secondList[j].Q * secondList[j].line.size() + consecutive[z].line.at(i).q()) /
                                (secondList.at(j).line.size()+1);
                        secondList[j].QM = - secondList[j].Q / secondList[j].M ;
                        //Aggiungo la linea alla struttura.
                        secondList[j].line.append(consecutive[z].line.at(i));
                        isTrue = true;
                    }
                }
                //Nessuna parete trovata = nuova singola parete!
                if (!isTrue) {
                    QList<SLAM::Geometry::LineSegment> altraProva;
                    ClusterAddTest::secondWallStruct temp2 = {consecutive.at(z).line.at(i).m(),
                                                               consecutive.at(z).line.at(i).q(),
                                                              - consecutive.at(z).line.at(i).q() / consecutive.at(z).line.at(i).m(),
                                                              altraProva};
                    temp2.line.append(consecutive[z].line[i]);
                    secondList.append(temp2);
                }
            }
        }

        qDebug() << "ed infine, l'ultimo cluster" <<endl;
        for (int count = 0; count < secondList.size(); count++ )
        {
            qDebug() << "Ora stampo secondList["<< count << "]" <<endl;
            qDebug() << "Che contiene "<<secondList[count].line.size()<<endl;
            for(int ccc = 0; ccc <secondList[count].line.size(); ccc++){
                qDebug() << "che contiene" << secondList[count].line[ccc].x1()
                        << "," << secondList[count].line[ccc].y1()
                        << " e " << secondList[count].line[ccc].x2()
                        << "," << secondList[count].line[ccc].y2() << endl;}}
    }


}
Example #6
0
static double lob8(double x)  { return l8(x); }