int main(int argc, char const *argv[])
{
	// 	     0
	// 	    / \
	//     1   2
	//    / \   \
	//   3   4   7
	//        \  /
	//         5 8
	//          \
	//           6
	TreeNode<int> n0(0);
	TreeNode<int> n1(1);
	TreeNode<int> n2(2);
	TreeNode<int> n3(3);
	TreeNode<int> n4(4);
	TreeNode<int> n5(5);
	TreeNode<int> n6(6);
	TreeNode<int> n7(7);
	TreeNode<int> n8(8);
	n0.left = &n1;
	n0.right = &n2;
	n1.left = &n3;
	n1.right = &n4;
	n4.right = &n5;
	n5.right = &n6;
	n2.right = &n7;
	n7.left = &n8;

	bool* matrix = solve(&n0);
	delete[] matrix;

	return 0;
}
예제 #2
0
main()
{
P1DIR = 0xFF;
while(1)
	{
	n1();
	delay(65000);
	n2();
	delay(65000);
	n3();
	delay(65000);
	n4();
	delay(65000);
	n5();
	delay(65000);
	n6();
	delay(65000);
	n7();
	delay(65000);
	n8();
	delay(65000);
	n9();
	delay(65000);
	n0();
	delay(65000);
	}
}
예제 #3
0
int main() {
    TreeNode n1(5);
    TreeNode n2(4);
    TreeNode n3(8);
    TreeNode n4(11);
    TreeNode n5(13);
    TreeNode n6(4);
    TreeNode n7(7);
    TreeNode n8(2);
    TreeNode n9(1);

    n1.left = &n2;
    n1.right = &n3;

    n2.left = &n4;
    n4.left = &n7;
    n4.right = &n8;

    n3.left = &n5;
    n3.right = &n6;

    n6.right = &n9;

    Solution sln;

    cout << sln.hasPathSum(&n1, 22) << endl;

    return 0;
}
int main(){
    node n1(1);
    node n2(2);
    node n3(3);
    node n4(4);
    node n5(5);
    node n6(6);
    node n7(7);
    node n8(8);
    node n9(9);
    node n10(10);
예제 #5
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void harsha()
{
 sss(xnxt,ynxt,h,ws);
 hhh(xnxt,ynxt,h,wh);
 rrr(xnxt,ynxt,h,wr);
 eee(xnxt,ynxt,h,we);
 eee(xnxt,ynxt,h,we);
 hhh(xnxt,ynxt,h,wh);
 aaa(xnxt,ynxt,h,wa);
 rrr(xnxt,ynxt,h,wr);
 sss(xnxt,ynxt,h,ws);
 hhh(xnxt,ynxt,h,wh);
 aaa(xnxt,ynxt,h,wa);
 xnxt+=s/2;
 n1(xnxt,ynxt,h,w1);
 n1(xnxt,ynxt,h,w1);
 iii(xnxt,ynxt,h,wi);
 ttt(xnxt,ynxt,h,wt);
 n8(xnxt,ynxt,h,w8);
 n8(xnxt,ynxt,h,w8);
}
예제 #6
0
파일: main.cpp 프로젝트: syawlaus/Leetcode
int main() {
    // init data
    TreeNode n6(6);
    TreeNode n2(2);
    TreeNode n8(8);
    TreeNode n0(0);
    TreeNode n4(4);
    TreeNode n7(7);
    TreeNode n9(9);
    TreeNode n3(3);
    TreeNode n5(5);

    n6.left = &n2;
    n6.right = &n8;

    n2.left = &n0;
    n2.right = &n4;

    n8.left = &n7;
    n8.right = &n9;

    n4.left = &n3;
    n4.right = &n5;

    // 测试 fillMapParents
    Solution sol;
    map<TreeNode*, TreeNode*> mapParents;
    sol.fillMapParents(&n6, mapParents);
    sol.printMapParents(mapParents);

    // 测试 depth
    sol.printAllNodesDepth(mapParents, &n6);

    // 测试 traverseUpward
    TreeNode* tempNode = &n2;
    sol.traverseUpward(tempNode, 1, mapParents);

    // 测试 lowestCommonAncestor
    TreeNode* v = &n2;
    TreeNode* w = &n4;
    TreeNode* lca = sol.lowestCommonAncestor(&n6, v, w);
    cout << endl << v->val << ", " << w->val << " 的 LCA 是 " << lca->val << endl << endl;

    v = &n2;
    w = &n8;
    lca = sol.lowestCommonAncestor(&n6, v, w);
    cout << endl << v->val << ", " << w->val << " 的 LCA 是 " << lca->val << endl << endl;

    return 0;
}
int main() {
    
    {
        /*
        _______6______
       /              \
    ___2__          ___8__
   /      \        /      \
   0      _4       7       9
         /  \
         3   5
         */
        Node n1( 6 );
        Node n2( 2 );
        Node n3( 8 );
        Node n4( 0 );
        Node n5( 4 );
        Node n6( 7 );
        Node n7( 9 );
        Node n8( 3 );
        Node n9( 5 );

        n1.left  = &n2;
        n1.right = &n3;
        n2.left  = &n4;
        n2.right = &n5;
        n3.left  = &n6;
        n3.right = &n7;
        n5.left  = &n8;
        n5.right = &n9;

        const Node * p = lca_bst( &n1, &n8, &n9 );
        assert( p == &n5 );
        
        p = lca_bst( &n1, &n2, &n8 );
        assert( p == &n2 );
        
        p = lca_bst( &n1, &n7, &n9 );
        assert( p == &n1 );

        Node n10( 10 );
        p = lca_bst( &n1, &n2, &n10 );
        assert( p == nullptr );
    }
    
    return 0;
}
예제 #8
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void shreeman()
{
 sss(xnxt,ynxt,h,ws);
 hhh(xnxt,ynxt,h,wh);
 rrr(xnxt,ynxt,h,wr);
 eee(xnxt,ynxt,h,we);
 eee(xnxt,ynxt,h,we);
 mmm(xnxt,ynxt,h,wm);
 aaa(xnxt,ynxt,h,wa);
 nnn(xnxt,ynxt,h,wn);
 xnxt+=s/2;
 n1(xnxt,ynxt,h,w1);
 n1(xnxt,ynxt,h,w1);
 iii(xnxt,ynxt,h,wi);
 ttt(xnxt,ynxt,h,wt);
 n8(xnxt,ynxt,h,w8);
 n9(xnxt,ynxt,h,w9);
}
예제 #9
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void dhanush()
{
 ddd(xnxt,ynxt,h,wd);
 hhh(xnxt,ynxt,h,wh);
 aaa(xnxt,ynxt,h,wa);
 nnn(xnxt,ynxt,h,wn);
 uuu(xnxt,ynxt,h,wu);
 sss(xnxt,ynxt,h,ws);
 hhh(xnxt,ynxt,h,wh);
 xnxt+=s/2;
 aaa(xnxt,ynxt,h,wa);
 xnxt+=s/2;
 n1(xnxt,ynxt,h,w1);
 n1(xnxt,ynxt,h,w1);
 iii(xnxt,ynxt,h,wi);
 ttt(xnxt,ynxt,h,wt);
 n1(xnxt,ynxt,h,w1);
 n8(xnxt,ynxt,h,w8);
}
예제 #10
0
int main()
{
	ListNode n6(10);
	ListNode n7(3);
	ListNode n8(45);
	ListNode n9(1);
	ListNode n10(38);
	ListNode n11(89);

	n6.next = &n7;
	n7.next = &n8;
	n8.next = &n9;
	n9.next = &n10;
	n10.next = &n11;

	ListNode* n = reverseList(&n6);

	while(n)
	{
		printf("%d->", n->val);
		n = n->next;
	}
    return 0;
}
예제 #11
0
int main()
{
    try
    {
        std::cout << "load:\t";
        {
            std::cout << "1, 12, 1.234, 5.678" << std::endl;

            boost::uint8_t n8(0);
            boost::uint32_t n32(0);
            boost::uint64_t n64(0);
            double ad64(0);
            double bd64(0);

            std::cout << "\tfrom little-endian:\t";
            {
                std::string const hex_little("010C0000005839B4C876BEF33F83C0CAA145B61640");
                std::cout << hex_little << std::endl;

                byte_array bytes;
                hex_to_bytes(hex_little, bytes);

                n8 = yatbinrw::load_little_endian<boost::uint8_t, sizeof(boost::uint8_t)>(bytes.begin());
                std::cout << "\t\tn8 = " << (int)n8 << std::endl;

                n32 = yatbinrw::load_little_endian<boost::uint32_t, sizeof(boost::uint32_t)>(bytes.begin() + 1);
                std::cout << "\t\tn32 = " << n32 << std::endl;

                n64 = yatbinrw::load_little_endian<boost::uint64_t, sizeof(boost::uint64_t)>(bytes.begin() + 1 + 4);
                std::memcpy(&ad64, &n64, sizeof(double));
                std::cout << "\t\tad64 = " << ad64 << " (" << n64 << " )" << std::endl;

                n64 = yatbinrw::load_little_endian<boost::uint64_t, sizeof(boost::uint64_t)>(bytes.begin() + 1 + 4 + 8);
                std::memcpy(&bd64, &n64, sizeof(double));
                std::cout << "\t\tbd64 = " << bd64 << " (" << n64 << " )" << std::endl;
            }

            std::cout << "\tfrom big-endian:\t";
            {
                std::string const hex_big("010000000C3FF3BE76C8B439584016B645A1CAC083");
                std::cout << hex_big << std::endl;

                byte_array bytes;
                hex_to_bytes(hex_big, bytes);        

                n8 = yatbinrw::load_big_endian<boost::uint8_t, sizeof(boost::uint8_t)>(bytes.begin());
                std::cout << "\t\tn8 = " << (int)n8 << std::endl;

                n32 = yatbinrw::load_big_endian<boost::uint32_t, sizeof(boost::uint32_t)>(bytes.begin() + 1);
                std::cout << "\t\tn32 = " << n32 << std::endl;

                n64 = yatbinrw::load_big_endian<boost::uint64_t, sizeof(boost::uint64_t)>(bytes.begin() + 1 + 4);
                std::memcpy(&ad64, &n64, sizeof(double));
                std::cout << "\t\tad64 = " << ad64 << " (" << n64 << " )" << std::endl;

                n64 = yatbinrw::load_big_endian<boost::uint64_t, sizeof(boost::uint64_t)>(bytes.begin() + 1 + 4 + 8);
                std::memcpy(&bd64, &n64, sizeof(double));
                std::cout << "\t\tbd64 = " << bd64 << " (" << n64 << " )" << std::endl;
            }
        } // load

        std::cout << "store:\t";
        {
            boost::uint8_t const n8(1);
            boost::uint32_t const n32(12);
            boost::uint64_t n64(0);
            double const ad64(1.234);
            double const bd64(5.678);

            std::cout << (int)n8 << ", " << n32 << ", " << ad64 << ", " << bd64 << std::endl;

            std::cout << "\tto little-endian:\t";
            {
                byte_array bytes; //empty
                std::back_insert_iterator<byte_array> it(std::back_inserter(bytes));

                yatbinrw::store_little_endian<boost::uint8_t, 1>(it, n8);
                yatbinrw::store_little_endian<boost::uint32_t, 4>(it, n32);

                std::memcpy(&n64, &ad64, sizeof(boost::uint64_t));
                yatbinrw::store_little_endian<boost::uint64_t, 8>(it, n64);

                std::memcpy(&n64, &bd64, sizeof(boost::uint64_t));
                yatbinrw::store_little_endian<boost::uint64_t, 8>(it, n64);

                std::string hex;
                bytes_to_hex(bytes, hex);
                std::cout << hex << std::endl;
            }

            std::cout << "\tto big-endian:";
            {
                byte_array bytes(1 + 4 + 8 + 8); // non-empty

                yatbinrw::store_big_endian<boost::uint8_t, 1>(bytes.begin(), n8);
                yatbinrw::store_big_endian<boost::uint32_t, 4>(bytes.begin() + 1, n32);

                std::memcpy(&n64, &ad64, sizeof(boost::uint64_t));
                yatbinrw::store_big_endian<boost::uint64_t, 8>(bytes.begin() + 1 + 4, n64);

                std::memcpy(&n64, &bd64, sizeof(boost::uint64_t));
                yatbinrw::store_big_endian<boost::uint64_t, 8>(bytes.begin() + 1 + 4 + 8, n64);

                std::string hex;
                bytes_to_hex(bytes, hex);
                std::cout << '\t' << hex << std::endl;
            }

        } // store
    }
    catch (std::exception const& e)
    {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}
예제 #12
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void sctensdigit(int a) //ten's place
{
 s=30;
 xnxt=400-45;
 ynxt=100;
 w9=w8=w4=w6=w5=w2=w3=w7=w0=wk=we=wf=wj=wl=wp=wr=ws=s/2;//1/2
 w1=wi=s/4;
 wg=wc=wh=wn=wb=wu=wt=wv=wx=wy=2*s/3;//2/3
 ww=wm=wa=wd=wo=wq=wz=3*s/4;//3/4
 h=s;//1
glColor3f(0,0,0);
glPointSize(2.0);
switch(a)
{
case 0:n0(xnxt,ynxt,h,w0);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 1:n1(xnxt,ynxt,h,w1);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 2: n2(xnxt,ynxt,h,w2);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 3: n3(xnxt,ynxt,h,w3);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 4: n4(xnxt,ynxt,h,w4);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 5: n5(xnxt,ynxt,h,w5);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 6: n6(xnxt,ynxt,h,w6);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 7: n7(xnxt,ynxt,h,w7);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 8: n8(xnxt,ynxt,h,w8);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

case 9: n9(xnxt,ynxt,h,w9);
xnxt-=(w1+sp);
ynxt-=3*s/2;
break;

default: break;
}
glFlush();
return ;
}
예제 #13
0
int main(){
	
	Scalar a("a",STRING,"Hello");
	Scalar b("b",STRING,"World");
	std::cout << " a                      : " << a << std::endl;
	std::cout << " b                      : " << b << std::endl; 
	Scalar c("c",STRING,"Hello");
	std::cout << " c                      : " << c << std::endl;
	std::cout << " a == b                 : " << (a == b) << std::endl;
	std::cout << " a == c                 : " << (a == c) << std::endl;
	std::cout << " a  < b                 : " << (a < b) << std::endl;
	std::cout << " c  < a                 : " << (c < a) << std::endl;
	std::cout << " b  < a                 : " << (b < a) << std::endl; 
	Scalar ga("ga",BOOLEAN,"M");
	Scalar gb("gb",BOOLEAN,"F");
	Scalar gc("gc",BOOLEAN,"F");
	Scalar d("d",STRING,"M");
	std::cout << " ga                     : " << ga << std::endl;
	std::cout << " gb                     : " << gb << std::endl;
	std::cout << " gc                     : " << gc << std::endl;
	std::cout << " d                      : " << d << std::endl;
	std::cout << " (ga == gb)             : " << (ga == gb) << std::endl;
	std::cout << " (gb == gc)             : " << (gb == gc) << std::endl;
	std::cout << " (ga == d)              : " << (ga == d) << std::endl;
	std::cout << " (gb < gc)              : " << (gb < gc) << std::endl;
	std::cout << " (ga < gc)              : " << (ga < gc) << std::endl;
	std::cout << " (gc < ga)              : " << (gc < ga) << std::endl;
	std::cout << " (ga < a)               : " << (ga < a) << std::endl;
	std::cout << " (b < gb)               : " << (b < gb) << std::endl;
	std::cout << "Testing Assignment and Copy operators" << std::endl;
	Scalar copy1(ga);
	std::cout << " copy1 of ga            : " << copy1 << std::endl;  
	std::cout << " name and type          : " << copy1.getName() << " = " << copy1.getValueType() << std::endl;
	Scalar e("e",STRING,"Namaste");
	std::cout << " e                      : " << e << std::endl;
	e=ga;
	std::cout << " e=ga                   : " << e << std::endl;
	std::cout << " name and type          : " << e.getName() << " = " << e.getValueType() << std::endl;
	e=a;
	std::cout << " e=a                    : " << e << std::endl;
	std::cout << " name and type          : " << e.getName() << " = " << e.getValueType() << std::endl;
	ga=a;
	std::cout << " ga=a                   : " << ga << std::endl;
	std::cout << " name and type          : " << ga.getName() << " = " << ga.getValueType() << std::endl;
	std::cout << "Testing Scalar variables of type ANY" << std::endl;
	Scalar anyVar("anyVar");
	std::cout << " name and type          : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl;
	std::cout << " anyVar                 : " << anyVar << std::endl;
	std::cout << " anyVar < ga            : " << (anyVar < ga) << std::endl;
	std::cout << " a < anyVar             : " << (a < anyVar) << std::endl;
	std::cout << " a == anyVar            : " << (a == anyVar) << std::endl;
	anyVar.set(STRING,"Wow");
	std::cout << " anyVar=Wow             : " << anyVar << std::endl;
	Scalar anyVar1("anyVar1");
	std::cout << " anyVar1                : " << anyVar1 << std::endl;
	std::cout << " name and type          : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl;
	anyVar1 = anyVar;
	std::cout << " anyVar1=anyVar         : " << anyVar1 << std::endl;
	std::cout << " name and type          : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl;
	Scalar anyVar2("anyVar2");
	std::cout << " anyVar2                : " << anyVar2 << std::endl;
	std::cout << " name and type          : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	anyVar = anyVar2;
	std::cout << " anyVar=anyVar2         : " << anyVar << std::endl;
	std::cout << " anyVar name and type   : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl;
	std::cout << " anyVar2 name and type  : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	Scalar anyType("anyType",ANY,"Testing Any");
	std::cout << " anyType                : " << anyType << std::endl;
	std::cout << " name and type          : " << anyType.getName() << " = " << anyType.getValueType() << std::endl;
	std::cout << " anyVar2 < anyType      : " << (anyVar2 < anyType) << std::endl;
	std::cout << " anyVar2 == anyType     : " << (anyVar2 == anyType) << std::endl;
	Scalar g1("g1",GENOTYPE,"120/120");
	Scalar g2("g2",GENOTYPE,"120/120");
	Scalar g3("g3",GENOTYPE,"112/118");
	Scalar g4("g4",GENOTYPE,"C/T");
	Scalar g5("g5",GENOTYPE,"A/A");
	std::cout << " g1                     : " << g1 << std::endl;
	std::cout << " name and type          : " << g1.getName() << " = " << g1.getValueType() << std::endl;
	anyVar2 = g1;
	std::cout << " anyVar2=g1             : " << anyVar2 << std::endl;
	std::cout << " name and type          : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl;
	std::cout << " g2                     : " << g2 << std::endl;
	std::cout << " g3                     : " << g3 << std::endl;
	std::cout << " g4                     : " << g4 << std::endl;
	std::cout << " g5                     : " << g5 << std::endl;
	std::cout << " name and type          : " << g5.getName() << " = " << g5.getValueType() << std::endl;
	std::cout << " g1 < g2                : " << (g1 < g2) << std::endl;
	std::cout << " g2 == g1               : " << (g2 == g1) << std::endl;
	std::cout << " g5 < g4                : " << (g5 < g4) << std::endl;
	std::cout << " g2 < g4                : " << (g2 < g4) << std::endl;
	std::cout << " g2 < e                 : " << (g2 < e) << std::endl;
	std::cout << " ga == g2               : " << (ga == g2) << std::endl;
	Scalar f("f",STRING,"123/125");
	Scalar g6Any("g6Any");
	std::cout << " g6Any                  : " << g6Any << std::endl;
	std::cout << " name and type          : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl;
	g6Any = f;
	std::cout << " g6Any=f                : " << g6Any << std::endl;
	std::cout << " name and type          : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl;
	g3 = g6Any;
	std::cout << " g3=g6Any               : " << g3 << std::endl;
	std::cout << " name and type          : " << g3.getName() << " = " << g3.getValueType() << std::endl;
	Scalar g7Inv("g7Inv");
	g7Inv.set(GENOTYPE,"0/0");
	std::cout << " g7Inv                  : " << g7Inv << std::endl;
	std::cout << " name and type          : " << g7Inv.getName() << " = " << g7Inv.getValueType() << std::endl;
	Scalar d1("d1",DATE,"1987-08-23");
	Scalar d2("d2",DATE,"1987-08");
	Scalar d3("d3",DATE,"[1987-1990]");
	Scalar d4("d4",DATE,"~2000-02-13");
	Scalar d5("d5",DATE,"1948");
	Scalar d6Any("d6Any");
	std::cout << " d1                     : " << d1 << std::endl;
	std::cout << " name and type          : " << d1.getName() << " = " << d1.getValueType() << std::endl;
	std::cout << " d6Any                  : " << d6Any << std::endl;
	std::cout << " name and type          : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl;
	d6Any = d1;
	std::cout << " d6Any=d1               : " << d6Any << std::endl;
	std::cout << " name and type          : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl;
	std::cout << " d2                     : " << d2 << std::endl;
	std::cout << " d3                     : " << d3 << std::endl;
	std::cout << " d4                     : " << d4 << std::endl;
	std::cout << " d5                     : " << d5 << std::endl;
	Scalar d7Inv("d7Inv");
	d7Inv.set(DATE,"2003-[03-04-12");
	std::cout << " d7Inv                  : " << d7Inv << std::endl;
	std::cout << " name and type          : " << d7Inv.getName() << " = " << d7Inv.getValueType() << std::endl;
	std::cout << " d1 < d2                : " << (d1 < d2) << std::endl;
	std::cout << " d2 == d1               : " << (d2 == d1) << std::endl;
	std::cout << " d2 == d3               : " << (d2 == d3) << std::endl;
	std::cout << " d3 < d2                : " << (d3 < d2) << std::endl;
	std::cout << " d5 < d4                : " << (d5 < d4) << std::endl;
	std::cout << " d2 < d4                : " << (d2 < d4) << std::endl;
	std::cout << " d2 < e                 : " << (d2 < e) << std::endl;
	std::cout << " ga == d2               : " << (ga == d2) << std::endl;
	Scalar d8Copy(d4);
	std::cout << " Copy of d4             : " << d8Copy << std::endl;
	std::cout << " name and type          : " << d8Copy.getName() << " = " << d8Copy.getValueType() << std::endl;
	std::cout << " d4 == d8Copy           : " << (d4 == d8Copy) << std::endl;
	
	Scalar n1("n1",NUMBER,"19-23");
	Scalar n2("n2",NUMBER,"18-38");
	Scalar n3("n3",NUMBER,"17");
	Scalar n4("n4",NUMBER,"~20");
	Scalar n5("n5",NUMBER,"48");
	Scalar n6Any("n6Any");
	std::cout << " n1                     : " << n1 << std::endl;
	std::cout << " name and type          : " << n1.getName() << " = " << n1.getValueType() << std::endl;
	std::cout << " n6Any                  : " << n6Any << std::endl;
	std::cout << " name and type          : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl;
	n6Any = n1;
	std::cout << " n6Any=n1               : " << n6Any << std::endl;
	std::cout << " name and type          : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl;
	std::cout << " n2                     : " << n2 << std::endl;
	std::cout << " n3                     : " << n3 << std::endl;
	std::cout << " n4                     : " << n4 << std::endl;
	std::cout << " n5                     : " << n5 << std::endl;
	Scalar n7Inv("n7Inv");
	n7Inv.set(NUMBER,"2003-[");
	std::cout << " n7Inv                  : " << n7Inv << std::endl;
	std::cout << " name and type          : " << n7Inv.getName() << " = " << n7Inv.getValueType() << std::endl;
	std::cout << " n1 < n2                : " << (n1 < n2) << std::endl;
	std::cout << " n2 == n1               : " << (n2 == n1) << std::endl;
	std::cout << " n2 == n3               : " << (n2 == n3) << std::endl;
	std::cout << " n3 < n2                : " << (n3 < n2) << std::endl;
	std::cout << " n5 < n4                : " << (n5 < n4) << std::endl;
	std::cout << " n2 < n4                : " << (n2 < n4) << std::endl;
	std::cout << " n2 < e                 : " << (n2 < e) << std::endl;
	std::cout << " ga == n2               : " << (ga == n2) << std::endl;
	Scalar n8Copy(n4);
	std::cout << " Copy of n4             : " << n8Copy << std::endl;
	std::cout << " name and type          : " << n8Copy.getName() << " = " << n8Copy.getValueType() << std::endl;
	std::cout << " n4 == n8Copy           : " << (n4 == n8Copy) << std::endl;
	Number::addNumberMissingValue("99");
	std::cout << "Added 99 as Number missing value" << std::endl;
	Scalar n8("n8",NUMBER,"99");
	std::cout << " n8=99                  : " << n8 << std::endl;
	return 0;
	
} 
예제 #14
0
파일: call.c 프로젝트: dod38fr/dyncall
void call_f8()
{
  n8(1,2,3,4,5,6,7,8);
}
void
dmz::StarfighterPluginSpaceBoxOSG::_create_box () {

   const String ImageName (_rc.find_file (_imgRc));

   osg::ref_ptr<osg::Image> img =
      (ImageName ? osgDB::readImageFile (ImageName.get_buffer ()) : 0);

   if (img.valid ()) {

      osg::Geode* geode = new osg::Geode ();

      osg::Geometry* geom = new osg::Geometry;

      osg::Vec4Array* colors = new osg::Vec4Array;
      colors->push_back (osg::Vec4 (1.0f, 1.0f, 1.0f, 1.0f));
      geom->setColorArray (colors);
      geom->setColorBinding (osg::Geometry::BIND_OVERALL);

      osg::StateSet *stateset = geom->getOrCreateStateSet ();
      stateset->setMode (GL_BLEND, osg::StateAttribute::ON);

#if 0
      osg::ref_ptr<osg::Material> material = new osg::Material;

      material->setEmission (
         osg::Material::FRONT_AND_BACK,
         osg::Vec4 (1.0, 1.0, 1.0, 1.0));

      stateset->setAttributeAndModes (material.get (), osg::StateAttribute::ON);
#endif

      osg::Texture2D *tex = new osg::Texture2D (img.get ());
      tex->setWrap (osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT);
      tex->setWrap (osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT);

      stateset->setTextureAttributeAndModes (0, tex, osg::StateAttribute::ON);

      stateset->setAttributeAndModes (new osg::CullFace (osg::CullFace::BACK));

      osg::Vec3Array *vertices = new osg::Vec3Array;
      osg::Vec2Array *tcoords = new osg::Vec2Array;
      osg::Vec3Array* normals = new osg::Vec3Array;

      const float Off (_offset);

      osg::Vec3 v1 (-Off, -Off, -Off);
      osg::Vec3 v2 ( Off, -Off, -Off);
      osg::Vec3 v3 ( Off,  Off, -Off);
      osg::Vec3 v4 (-Off,  Off, -Off);
      osg::Vec3 v5 (-Off, -Off,  Off);
      osg::Vec3 v6 ( Off, -Off,  Off);
      osg::Vec3 v7 ( Off,  Off,  Off);
      osg::Vec3 v8 (-Off,  Off,  Off);

      osg::Vec3 n1 ( 1.0,  1.0,  1.0);
      osg::Vec3 n2 (-1.0,  1.0,  1.0);
      osg::Vec3 n3 (-1.0, -1.0,  1.0);
      osg::Vec3 n4 ( 1.0, -1.0,  1.0);
      osg::Vec3 n5 ( 1.0,  1.0, -1.0);
      osg::Vec3 n6 (-1.0,  1.0, -1.0);
      osg::Vec3 n7 (-1.0, -1.0, -1.0);
      osg::Vec3 n8 ( 1.0, -1.0, -1.0);

      n1.normalize ();
      n2.normalize ();
      n3.normalize ();
      n4.normalize ();
      n5.normalize ();
      n6.normalize ();
      n7.normalize ();
      n8.normalize ();

//      const float F1 (5.0f);
//      const float F2 (2.5f);
      const float F1 (5.0f);
      const float F2 (2.5f);
      int count = 0;

      // 1
      vertices->push_back (v1);
      vertices->push_back (v2);
      vertices->push_back (v3);
      vertices->push_back (v4);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n1);
      normals->push_back (n2);
      normals->push_back (n3);
      normals->push_back (n4);
      count += 4;

      // 2
      vertices->push_back (v4);
      vertices->push_back (v3);
      vertices->push_back (v7);
      vertices->push_back (v8);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n4);
      normals->push_back (n3);
      normals->push_back (n7);
      normals->push_back (n8);
      count += 4;

      // 3
      vertices->push_back (v8);
      vertices->push_back (v7);
      vertices->push_back (v6);
      vertices->push_back (v5);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n8);
      normals->push_back (n7);
      normals->push_back (n6);
      normals->push_back (n5);
      count += 4;

      // 4
      vertices->push_back (v5);
      vertices->push_back (v6);
      vertices->push_back (v2);
      vertices->push_back (v1);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n5);
      normals->push_back (n6);
      normals->push_back (n2);
      normals->push_back (n1);
      count += 4;

      // 5
      vertices->push_back (v3);
      vertices->push_back (v2);
      vertices->push_back (v6);
      vertices->push_back (v7);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n3);
      normals->push_back (n2);
      normals->push_back (n6);
      normals->push_back (n7);
      count += 4;

      // 6
      vertices->push_back (v1);
      vertices->push_back (v4);
      vertices->push_back (v8);
      vertices->push_back (v5);
      tcoords->push_back (osg::Vec2 (0.0, 0.0));
      tcoords->push_back (osg::Vec2 (0.0, F1));
      tcoords->push_back (osg::Vec2 (F2, F1));
      tcoords->push_back (osg::Vec2 (F2, 0.0));
      normals->push_back (n1);
      normals->push_back (n4);
      normals->push_back (n8);
      normals->push_back (n5);
      count += 4;

      geom->setNormalArray (normals);
      geom->setNormalBinding (osg::Geometry::BIND_PER_VERTEX);
      geom->addPrimitiveSet (new osg::DrawArrays (GL_QUADS, 0, count));
      geom->setVertexArray (vertices);
      geom->setTexCoordArray (0, tcoords);
      geode->addDrawable (geom);

      _box = new osg::MatrixTransform ();

      _box->addChild (geode);
   }
   else { _log.error << "Failed to load: " << _imgRc << ":" << ImageName << endl; }
}